PDA

View Full Version : 2 actions off of 1 link - JavaScript error


Elegiac
07-30-2005, 05:13 AM
I do believe that I am in the right forum for this. If not, I apologize.

I have this website I've been working on and unfortunately I've run into a problem: everytime I click a button, the JavaScript Console pops up. I assume this is because I've done something wrong. What I want to do is to have two seperate iFrames load different content when the user clicks a button. For instance, this is what I have for one of the links:

<a href="javascript:" onclick="parent.frames['right_body'].location = 'http://boomspeed.com/nateproject/booking.htm'; parent.frames['left_body'].location = 'http://boomspeed.com/nateproject/emailselection.htm';"><IMG SRC="http://www.boomspeed.com/nateproject/button_email.jpg" ALT="" WIDTH=89 HEIGHT=24 border="0"></a>

However, I do not have anything in my <head>, and I assume that is the problem. If this is not the problem, feel free to point me in the right direction as well.

EDIT: I just read the FAQ section, which made me realize "javascript:" isn't the best way to go. Is there an alternative way for me to make this work?

_Aerospace_Eng_
07-30-2005, 05:41 AM
Try this


<a href="http://boomspeed.com/nateproject/booking.htm" target="right_body" onclick="parent.frames['left_body'].location = 'http://boomspeed.com/nateproject/emailselection.htm';"><img src="http://www.boomspeed.com/nateproject/button_email.jpg" alt="" width="89" height="24" border="0"></a>


This way if the user has javascript disabled they will at least see one page. If the link is inside of an iframe then, do something like this


<a href="http://boomspeed.com/nateproject/booking.htm" target="right_body" onclick="parent.frames['right_body'.location=this.href;parent.frames['left_body'].location = 'http://boomspeed.com/nateproject/emailselection.htm';return false"><img src="http://www.boomspeed.com/nateproject/button_email.jpg" alt="" width="89" height="24" border="0"></a>

Elegiac
07-30-2005, 05:45 AM
I tried that, but unfortunately it messed up my layout. The button is now a little higher than the rest of the buttons and therefore screws up everything. :(

_Aerospace_Eng_
07-30-2005, 05:49 AM
I made no real change to the way you had it before. I added quotes where necessary. Not sure why it won't work. Sighs if you must, use javascript:; with a semicolon rather than javascript: without it.

Elegiac
07-30-2005, 06:56 AM
Well I've decided just to redo the site another way. I appreciate your help a lot though, or else I'd still be trying to fix my older problems.

Thanks again.