Do you have a question? Post it now! No Registration Necessary
- Martin Brown
January 18, 2021, 5:00 pm

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
<input onclick="alert(self.location);
alert(window.frames.length);
window.frames[0].location='index.htm';
alert(window.frames[0].location);
alert(42)"
value="toggle" type="button">
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.
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
<input onclick="alert(self.location);
alert(window.frames.length);
window.frames[0].location='index.htm';
alert(window.frames[0].location);
alert(42)"
value="toggle" type="button">
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
Regards,
Martin Brown
Site Timeline
- » 0805 Kevlin sense connections
- — Next thread in » Electronics Design
-
- » OT China seeing a major resurgence in COVID-19
- — Previous thread in » Electronics Design
-
- » Auction in Fremont, ca NOW
- — Newest thread in » Electronics Design
-
- » Amateur electronics in danger due to lack of DIP ICs
- — Last Updated thread in » Electronics Design
-
- » pemohon
- — The site's Newest Thread. Posted in » Electronics Computer-Aided Design
-