Javascript help with iframes

Jan 18, 2021 0 Replies

I normally manage to avoid this stuff but I need to have a button that toggles between old pages ending .htm and new ones ending .html



I thought it would be fairly easy but I have hit a snag.



window.frames[0].location = "index.htm" works OK



alert(window.frames[0].location) fails mysteriously



I have also tried qualifying it .href etc no joy :(



The actual code is


The output is: fully qualified filename for the HTML file 1 frames[0] changes to show contents of index.htm (as expected) crashes out here



In short I want a foolproof way of obtaining the URL name of the page being displayed in a particular IFRAME so that I can adjust it. (adding or removing a trailing "L" according to taste)



I happen to know in this case that it will be in frames[0].



I have never encountered a situation where you can successfully assign a string to a variable/property and then not be able to look at it again.



Can anyone see what I am doing wrong? I can't! Thanks for any enlightenment.


Regards, Martin Brown

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required