www.webdeveloper.com
Results 1 to 4 of 4

Thread: linking an img in javascript

  1. #1
    Join Date
    Apr 2012
    Posts
    2

    Question linking an img in javascript

    Hi,

    I'm having some issues trying to figure out how to properly link an image in a javascript to an outside url.
    I am not very familiar with javascript, though I have used it sometimes in random projects. After trying to search for ways to add a link and failing miserably I decided to turn to here for help.

    Is there some way to insert a link to a different site for the image used in here?

    This javascript was created by a generator in order to created "a hover ad":
    <SCRIPT language='JavaScript' type=text/javascript>
    <!--
    document.write("<table width='134' height='80' border='0' cellspacing='0' cellpadding='1' style='display:none;position:absolute;top:10px;left:10px;empty-cells:hide' id='v1771333963135801v181'>");document.write("<tr><td style='background: #b8d26d'>");document.write("<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'>");document.write("<tr height='1'><td>");document.write("<table width='100%' border='0' cellspacing='1' cellpadding='0' style='background: #b8d26d; color: #FFFFFF; cursor: default'><tr style='font-family: Arial, sans-serif; font-size: 10pt; font-weight: bold'><td>Yhteistyössä:");document.write("<td style='width: 20px; cursor: pointer;' onclick='javascript:v1771333963135801v183();'>-");document.write("<td style='width: 20px; cursor: pointer;' onclick='javascript:v1771333963135801v184();'>X");document.write("</table>");document.write("<tr><td>");document.write("<table width='100%' height='100%' id='v1771333963135801v185' border='0' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'>");document.write("<tr>");document.write("<td>");document.write("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\"><tr><td><p align=\"center\"><img border=\"0\" src=\"kumppanibanneri_simple.png\"></td></tr></table>");document.write("</table></table></table>"); if ( document.getElementById ) v1771333963135801v186 = document.getElementById ( "v1771333963135801v181" ); else v1771333963135801v186 = document.all ["v1771333963135801v181"]; var v1771333963135801v187 = undefined; var v1771333963135801v188 = false; function v1771333963135801v183 ( ) { if ( document.getElementById ) v189 = document.getElementById ( "v1771333963135801v185" ); else v189 = document.all ["v1771333963135801v185"]; if ( v189.style.display == "none" ) { v189.style.display = ""; v1771333963135801v186.style.height = "80px"; } else { v189.style.display = "none"; v1771333963135801v186.style.height = "20px"; } } function v1771333963135801v184 ( ) { v1771333963135801v186.style.display = "none"; v1771333963135801v188 = true; } var v1771333963135801v175, v1771333963135801v176; var v1771333963135801v190, v1771333963135801v191; function v1771333963135801v192 ( ) { return ( ( window.pageXOffset ) ? window.pageXOffset : document.body.scrollLeft ) + v1771333963135801v190; } function v1771333963135801v193 ( ) { return ( ( window.pageYOffset ) ? window.pageYOffset : document.body.scrollTop ) + v1771333963135801v191; } function v1771333963135801v194 ( ) { var v195 = 500; v1771333963135801v186.style.top = v1771333963135801v193 ( ); v1771333963135801v186.style.left = v1771333963135801v192 ( ); setTimeout ( "v1771333963135801v194 ( );", v195 ); } function v1771333963135801v197 ( v198 ) { if ( v1771333963135801v190 != v1771333963135801v175 || v1771333963135801v191 != v1771333963135801v176 ) { if ( v1771333963135801v190 != v1771333963135801v175 ) if ( Math.abs ( v1771333963135801v190 - v1771333963135801v175 ) <= v1771333963135801v199 ) v1771333963135801v190 = v1771333963135801v175; else if ( v1771333963135801v190 < v1771333963135801v175 ) v1771333963135801v190 += v1771333963135801v199; else v1771333963135801v190 -= v1771333963135801v199; if ( v1771333963135801v191 != v1771333963135801v176 ) if ( Math.abs ( v1771333963135801v191 - v1771333963135801v176 ) <= v1771333963135801v199 ) v1771333963135801v191 = v1771333963135801v176; else if ( v1771333963135801v191 < v1771333963135801v176 ) v1771333963135801v191 += v1771333963135801v199; else v1771333963135801v191 -= v1771333963135801v199; v1771333963135801v186.style.top = v1771333963135801v193 ( ); v1771333963135801v186.style.left = v1771333963135801v192 ( ); setTimeout ( "v1771333963135801v197 ( " + v198 + " );", 20 ); } else if ( v198 ) v1771333963135801v194 ( ); else v1771333963135801v186.style.display = "none"; } function v1771333963135801v200 ( v201, v202 ) { v1771333963135801v175 = v201; v1771333963135801v176 = v202; v1771333963135801v190 = v201; v1771333963135801v191 = v202; var v205 = 0, v206 = 0; v205 = -v201 -134; v206 = -v202 -80; if ( v205 != 0 && v206 != 0 ) if ( Math.abs ( v205 ) < Math.abs ( v206 ) ) v206 = v206 / Math.abs ( v206 ) * Math.abs ( v205 ); else v205 = v205 / Math.abs ( v205 ) * Math.abs ( v206 ); v1771333963135801v190 += v205; v1771333963135801v191 += v206; v1771333963135801v186.style.top = v1771333963135801v193 ( ); v1771333963135801v186.style.left = v1771333963135801v192 ( ); v1771333963135801v186.style.display = ""; v1771333963135801v197 ( true ); } function v1771333963135801v196 ( ) { if ( v1771333963135801v188 ) return; v1771333963135801v199 = undefined; var v205 = 0, v206 = 0; var v201 = v1771333963135801v175, v202 = v1771333963135801v176; v205 = -v201 -134; v206 = -v202 -80; if ( v205 != 0 && v206 != 0 ) if ( Math.abs ( v205 ) < Math.abs ( v206 ) ) v206 = v206 / Math.abs ( v206 ) * Math.abs ( v205 ); else v205 = v205 / Math.abs ( v205 ) * Math.abs ( v206 ); v1771333963135801v175 += v205; v1771333963135801v176 += v206; v1771333963135801v186.style.top = v1771333963135801v193 ( ); v1771333963135801v186.style.left = v1771333963135801v192 ( ); v1771333963135801v186.style.display = ""; v1771333963135801v197 ( false ); } var v1771333963135801v199 = 16.970725498515062; setTimeout ( "v1771333963135801v200 ( 1, 1, 16.970725498515062 );", 1500 ); var v1771333963135801v217, v1771333963135801v218; function v1771333963135801v219 ( v220 ) { v221 = ( document.all ) ? event.clientX : v220.clientX; v222 = ( document.all ) ? event.clientY : v220.clientY; v1771333963135801v190 += v221 - v1771333963135801v217; v1771333963135801v191 += v222 - v1771333963135801v218; v1771333963135801v217 = v221; v1771333963135801v218 = v222; v1771333963135801v186.style.top = v1771333963135801v193 ( ); v1771333963135801v186.style.left = v1771333963135801v192 ( ); } function v1771333963135801v223 ( ) { } function v1771333963135801v224 ( ) { document.onmousemove = v1771333963135801v223; document.onmouseup = v1771333963135801v223; } function v1771333963135801v225 ( v220 ) { v1771333963135801v217 = ( document.all ) ? event.clientX : v220.clientX; v1771333963135801v218 = ( document.all ) ? event.clientY : v220.clientY; document.onmousemove = v1771333963135801v219; document.onmouseup = v1771333963135801v224; } v1771333963135801v186.onmousedown = v1771333963135801v225;
    //-->
    </SCRIPT>
    Any help you might be able to provide is appreciated. Thank you.

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    <img border=\"0\" src=\"kumppanibanneri_simple.png\" onClick=\"window.location.href='http://www.domain.com/'\" style=\"cursor:pointer;\"> should do it.

  3. #3
    Join Date
    Apr 2012
    Posts
    2
    Oh wow, thank you so much! ^_^ This made my day. ♥
    Phew.

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Glad I could help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles