View Full Version : iframe.src and other js error...

06-17-2007, 01:48 PM
I've been learning JS for about 6 months now, but for some reason I'm getting two error that I have no idea how to fix...


Firstly, I have a function called resize which is called onload and onresize, but when called onload, it says that the Iframe (id="spare") has no properties, and the onresize doesn't even work.

Secondly, the search function gets the value of the selected option in the dropdown list, and adds the text input value to the end and sets it as the iframes src.
This does not work either.

Please give me as much help as you can, thank you.

06-17-2007, 05:07 PM
when you set an event handler with a function you do not include ()

= resize(); //mean you want to execute the code right now on the spot
= resize; //means you want to store a 'reference' to this method

so it should be:



06-17-2007, 07:37 PM
Ok, but it still doesn't work, even with that changed.

06-18-2007, 12:03 AM
How do you expect us to help you if your link doesn't work?

06-18-2007, 10:33 AM
Sorry, the host is terrible, and decided that it was potentially a virus...

When I get home I'll put it on a different server.

06-18-2007, 12:03 PM
window.resize=resize;I believe that the above code should read window.onresize=resize. Just thought Id point that out in case Jacka copied and pasted it.

06-18-2007, 02:14 PM
I found one of my mistakes, not putting "px" after the css width and height, but the search still doesn't work.

If you type "javascript: search();", the search works as intended, but for some reason the onsubmit event isn't working.

06-19-2007, 03:21 PM
Any ideas?

06-19-2007, 07:00 PM
Yes study javascript a bit more mainly the reserved words. search, and select are both reserved words in Javascript so you can't use them for function names or variables. change your form name to search1 and your select name to select1. Use this for your search function

function searchit(){
You will also need to change search() in your onsubmit to searchit()

06-19-2007, 07:03 PM
Ah, thanks a lot Aero, it's very much appreciated!