Forum Moderators: open
I'm new to JS. I have a page with few javascript functions and some of these functions do not work. But some of lines in called function work.
For example, I have function:
function startScript()
{
document.getElementById('waitImage').src='$photoUploadedUrl';
document.photoSubmit.reset();
window.parent.document.getElementById('photoFrame').location = 'http://www.example.com';
document.write('ok');
}
I call this function by this:
window.onload = startScript();
First two lines of this code work, but other two do not work. I've checked syntax a lot of times and it seems ok to me.
I also have another functions that have same problem.
I'm totally confused with JS. I never met with such strange problems in other languages.
I wonder did I miss something or it's JS's bug?
use alert() alot if your code isn't working it will help you track down a malfunctioning line.
and seeing as your code dosn't work from line 3 on it suggests line 3 is wrong.
Here I think that window.parent. I think it should be parent.window.
I think that the code in this case can be shortened to:
function startScript()
{
document.getElementById('waitImage').src='$photoUploadedUrl';
document.photoSubmit.reset();
parent.getElementById('photoFrame').location = 'http://www.example.com';
alert('ok');
}
Note: I have said I think a lot here because my knowlage on the window object is sketchy at best