[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

onmouseon and target

Posted on 2000-01-18
4
Medium Priority
?
1,449 Views
Last Modified: 2010-05-18
i use this code which has images in the left frame that change to one image when the mouse is over them and to another image when they are clicked

(each option has 3 images)

but when i try to add in target=_top
into
 
<A HREF="Javascript:void(doClick(2))" onMouseOver="doOver(2); return true" onMou
seOut="doOut(2)">
<IMG SRC="../FRENCH.jpg" BORDER="0"></A>      


like this

<A HREF="Javascript:void(doClick(2))" onMouseOver="doOver(2); return true" onMou
seOut="doOut(2)" target=_top>
<IMG SRC="../FRENCH.jpg" BORDER="0"></A>      


then the page wont load up...

any ideas?
thanks





------------------
<HTML>
<HEAD>



<SCRIPT LANGUAGE="Javascript"><!--
var IMAGE_COUNT=3;
var SelectedImage=-1;

var srcsOut = new Array(IMAGE_COUNT);
var srcsOver = new Array(IMAGE_COUNT);
var srcsClick = new Array(IMAGE_COUNT);
var urls = new Array(IMAGE_COUNT);

srcsOut[0] = "../MAIN.jpg";
srcsOut[1] = "../REG.jpg";
srcsOut[2]= "../FRENCH.jpg";            


srcsOver[0] = "../MAINON.jpg";
srcsOver[1] = "../REGON.jpg";
srcsOver[2] = "../FRENCHON.jpg";  


srcsClick[0] = "../MAINB.jpg";
srcsClick[1] = "../REGB.jpg";
srcsClick[2] = "../FRENCHB.jpg";        


urls[0]="main.html";
urls[1]="http://me/cgi-bin/test.cgi";
urls[2]="protected_dir/index.html";  


function doOver(which){
if(SelectedImage!=which)document.images[which].src=
srcsOver[which];
}

function doOut(which){
if(SelectedImage!=which)document.images[which].src=
srcsOut[which];
}

function doClick(which){
if(SelectedImage!=-1)document.images[SelectedImage].src=
srcsOut[SelectedImage];
document.images[which].src=srcsClick[which];
SelectedImage=which;
top.window.main.location=urls[which];
}
//--></SCRIPT>

</HEAD>                                

<BODY BGCOLOR=FFFFFF TEXT=000000 LINK=0000FF VLINK=800080>
<br>
<A HREF="Javascript:void(doClick(0))"onMouseOver="doOver(0); return true" onMous
eOut="doOut(0)">
<IMG SRC="../MAIN.jpg" BORDER="0"></A>
<A HREF="Javascript:void(doClick(1))"onMouseOver="doOver(1); return true" onMous
eOut="doOut(1)">
<IMG SRC="../REG.jpg" BORDER="0"></A>
<A HREF="Javascript:void(doClick(2))" onMouseOver="doOver(2); return true" onMou
seOut="doOut(2)">
<IMG SRC="../FRENCH.jpg" BORDER="0"></A>      



</BODY>
</HTML>

--------------------
                                 
0
Comment
Question by:boofulls
  • 2
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 200 total points
ID: 2362529
Wrong place.

Target is not valid on a javascript href...

You should change the line

top.window.main.location=urls[which];

to

top.location=urls[which];

in doClick

Michel

0
 

Author Comment

by:boofulls
ID: 2362887
but what if i want some to target _top and others to target "main"

ie
if image one and two are to be
target=_top
and image three is to be
target="main"

thanks
0
 

Author Comment

by:boofulls
ID: 2362917
i did a doclick2 function and changed the code as u mentioned
thanks
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2364611
function doClick(whichImage,where) {
   eval(where+'.location=urls['+whichImage+']');
}

..
..


<A HREF="javascript:;" onCLick="doClick(0,'main')"
onMouseOver="doOver(0); return true"
onMouseOut="doOut(0)"><IMG SRC="../MAIN.jpg" BORDER="0"></A>
<A HREF="javascript:;" onCLick="doClick(1,'top')"
onMouseOver="doOver(1); return true"
onMouseOut="doOut(1)"><IMG SRC="../MAIN.jpg" BORDER="0"></A>

0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question