Jump to content

[SOLVED] JS With The A Href Tag


tarun

Recommended Posts

are you trying to change images on mouse hover than try

<head>
<script language='javascript'>
if (document.images) {
poth00=new Image
poth00.src='http://url.net/image1.png'
poth01=new Image
poth01.src='http://url.net/image2.png'
}</script>
</head>
<img name='poth' src='default image url here'>
<a href='#' onmouseover='document.poth.src=poth01.src' onmouseout='document.poth.src=poth00.src'>hover mouse here</a>

This Is My HTML

<a href='' onMouseover=document.write('<img src=img.jpg>') ''>Hover Mouse Here</a>

And It Doesn't Work

I Get The Error "Unterminated string constant"

 

 

Can AnyBody Help Me Please

Thnx,

Tarun

 

<a href='' onMouseover="document.write('<img src=\'img.jpg\'>')">Hover Mouse Here</a>

 

You need quotes around the HTML attributes.

<a href='' onMouseover="document.write('<img src=\'img.jpg\'>')">Hover Mouse</a>

the code above will overwrite the entire browser window with the image in ie. In ff it will overwite the window as well but will keep displaying the hourglass as if it's never loaded. Is that what you wanted?  Instead maybe try this:

<a href="#" onMouseover="document.getElementById('someDIVid').innerHTML = '<img src=\"img.jpg\">';">Hover Mouse</div>

--will display the image within the div with the specified id

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.