I've inherited some Javascript, this JS did once work, but for some reason it no longer works.
I have the following script, bear in mind I've chopped this down and outlined the offending sections only:
function top_frame() {
top_frame = top.frames[0].document;
top_frame.write('<HTML><BODY topmargin=0 leftmargin=0 marginheight=0 marginwidth=0><IMG SRC="'+image_url+'/options_top.gif" HEIGHT=25 WIDTH=300></BODY></HTML>')
// top_frame.write('<HTML><BODY BGCOLOR="#339999"><IMG SRC="images/global/options_top.gif" WIDTH=300 HEIGHT=25 ALT="Product options editor" BORDER="0"></BODY></HTML>')
top_frame.close();
}
function bottom_frame() {
bottom_frame = top.frames[2].document;
bottom_frame.write('<HTML><BODY topmargin=0 leftmargin=0 marginheight=0 marginwidth=0><A HREF="javascript:top.update_options()"><IMG SRC="'+image_url+'/options_end.gif" WIDTH=300 HEIGHT=30 ALT="Update and close" BORDER="0"></A></BODY></HTML>')
bottom_frame.close();
}
</SCRIPT>
<frameset rows="26,*,31" frameborder="NO" border="0" framespacing="0">
<frame src="javascript:top.top_frame()"
scrolling="NO" marginwidth="0" marginheight="0" frameborder="NO"
NAME="options_top">
<frame src="javascript:top.show_start()"
marginwidth="0" marginheight="0" frameborder="NO" scrolling="auto"
NAME="options_main">
<frame src="javascript:top.bottom_frame()"
scrolling="NO" marginwidth="0" marginheight="0" frameborder="NO"
NAME="options_bottom">
</frameset>
</HTML>
I'm invoking the functions bottom_frame(), show_start() and top_frame() in the HTML at the bottom of the page. However, I see the following message in the errors tab:
TypeError: top.bottom_frame is not a function
I see this on each function call. Can anyone suggest what the issue is here?
Don't use the same name for variable that you have used for the function name
For example, if you define a function a as
function a(){a =1};
and invoke this a(), it will output 1;
but next time it will give an error
Uncaught TypeError: a is not a function
because when it was executed it redefined a to a non-function type value i.e. 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With