View Full Version : javascript problems

7th March 2005, 06:07 PM
I'm having some problems with my java script on my web site, as i'm not really into javascript, and have just been copying bits and pieces from here and there, i've run into problems...

here is my link/code/tag thing
// images/Captain-Man-Page_06.gif (javascript:;)

7th March 2005, 07:58 PM
I'm a little rusty, but I'll try my best to answer this before it slips off the New Posts list.

The offending line:

onClick="window.open('cm/cm003.html','Captain Man, issue 3','toolbar=no,status=no,menubar=no,scrollbars=yes ,resizable=yes,height=800,width=1000,newWin.focus( )');

Firstly: Captain Man, issue 3
is the name the browser references the window by - not a title for the window.
Keep this name as a single word. For example lets call it newWin

Secondly: newWin.focus()
This command tells the browser to bring the window called newWin into focus.
This makes it the active window. What you need to do is make sure the window name here and the one used in window.open() are the same.

Thirdly: return false
Shouldn't really be neccessary. This is not within a function, so therefore isn't returning anything anyway.

Lastly: JavaScript and Java are 2 completely different things
Don't interchange these names - or someone who knows the difference will point it out.
More info... [Google - JavaScript is not Java] (http://www.google.com.au/search?q=%22javascript+is+not+java%22&sourceid=mozilla-search&start=0&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official)

I hope I haven't missed anything! Best of luck.

7th March 2005, 08:08 PM
Wait - more to fix!

The final code should be:

<a href="javascript:;" onClick="window.open('cm/cm003.html','newWin','toolbar=no,status=no,menubar =no,scrollbars=yes,resizable=yes,height=800,width= 1000'); newWin.focus();"><img src="images/Captain-Man-Page_06.gif" alt="Captain Man Robo-Toaster" width="374" height="43" border="0" id="Captain_Man_Page_06" /></a>
newWin.focus() was inside window.open(). These are 2 seperate functions, so it would be wrong for them to be nested inside each other.

You also might want to remove id="Captain_Man_Page_06". It doesn't really do anything unless you want to access it by this name using JavaScript, or CSS.

Apart from that, it should all work now.

8th March 2005, 07:48 PM
thanks geektechnu, now it works, but it still gets errors saying that newWin is not defined
at Char 122

wait just checking what 122 is....