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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.