PDA

View Full Version : Simple (?) Javascript problem


Subwaydesigns
02-02-2003, 05:46 PM
Hi,
Somehow I can't get this script to work, the error might be in the syntax... I'm not an expert so I'd be really grateful it if you could check it for mistakes.


function loadPage() {
if (window.frames['frame'].location != 'main.html') {
ed = document.getElementById("frame")
ed.setAttribute("src", "main.html") }
}

And I use the body onLoad event to call the function.

Basically what happens is I have a frame who's source I change (from an external flash movie).
When I reload the main page (in which the frame is located), the frame's src is the same as the last page that I visited (If I have a button making the frame's src "about.html", the frame reloads "about.html" when I refresh the main page).
I want the frame to load "main.html" whenever I refresh the main page AND the frame's src is not "main.html". Why won't my code work? Right now it refreshes the frame everytime I reload the main page, regardless of the current frame src.
ugh... hoe that was clear enough, if you have any questions please ask :)

Thanks in advance.

_s.

Subwaydesigns
02-02-2003, 07:37 PM
I've got it fixed; for reference the problem was that .location had to be a complete URL, as in window.frames['frame'].location != 'http://www.whatever.com/folder/file.html'