I am trying to open a link on image click using follwoing code
<img src="AllScripts/SliderImages/images/1Main.png" alt="" title="" onclick="openSliderImage(id);" onmouseover="this.style.cursor='hand'" width="800px" height="300px" id="http://www.google.com" />
It is working fine but when generating image using c# write code using response.write code it doesn’t work and goes on the follwoing link
http://localhost:1234/AllScripts/SliderImages/images/1Main.png
Follwoing code is used to write html
<% {
Response.Write(SlidingImages);
}
%>
I know it pick the image src rather then image id on image click but why?
This is the javascript function
function openSliderImage(id) {
alert(id);
window.open(id, '_blank');
}
Using ids like that to open links seem like a hack. I would just output the url to like link it has to open as a parameter to the function directly.
Your code doesn’t run cause it will look for a javascript variable by the name ‘id’.