开发者

I need help with javascript

I have a javascipt code something like

<script type="text/javascript" src="http://ads..........." ></script>

this script shows a 开发者_如何学JAVAbanner. i want to use onClick event with this script without disturbing the banner click. is that possible?


Yes if the banner is not wrapped in an iframe that is cross domain, but the question is... onClick event on what? the banner? the page? another element?

use addEventListener/addEvent or a JS library to add the event. If this kills the banner be sure to take the banner's onclick property and add it as well to the banner.


Those scripts usually produce dynamic content via document.write. If you examine the resulting DOM (e.g., via Firebug in FireFox, or Dev Tools in Chrome, etc.), you can get an idea of what the resulting structure is. If there's a top-level image or link, you can hook it with a DOM2 handler (addEventListener is the standard form; IE uses attachEvent instead; Javascript libraries like Prototype or jQuery can help iron out the inconsistencies for you). That would let you see a click without disturbing its underlying action (provided you don't cancel the event, but you have to do that on purpose, so you should be okay.)


Process that click through the handler, e.g.

<a href="#" onclick="javascript:yourFunctionThatEventuallyDoesTheRedirect('URLToRedirect')"><!-- Banner image --></a>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜