2

Have been trying to fix this for the past hour.

Here goes:

<script type="text/javascript">
 function openAd(adType, urlToGo) {
 pageTracker._trackPageview(adType);
 window.open(urlToGo, '_blank');
 return false;
 }
</script>

Anyone have any idea why this doesn't work?

Called it like onclick="openAd('/Ads/MMA_Front_Page.com', 'http://www.anrdoezrs.net/click-4706163-10919130');"

I uploaded a live version at:

http://www.easymuaythai.com/

Pointy
415k62 gold badges600 silver badges633 bronze badges
asked Dec 10, 2011 at 23:06
13
  • 4
    open your browser's javascript console, and see what the error it returns sais. Commented Dec 10, 2011 at 23:09
  • 2
    Are you using Firebug (Firefox) or the Webkit inspector (Safari and Chrome)? Both are excellent tools for debugging Javascript. A disclosure of the errors or behavior exhibited from those tools would make your question more clear. Commented Dec 10, 2011 at 23:09
  • 1
    Aren't you passing two arguments where your function accepts only one? Commented Dec 10, 2011 at 23:09
  • 2
    Nice code, it does three things my browser is configured to block: (1) analytics (2) ads (3) popups in general. Commented Dec 10, 2011 at 23:16
  • 1
    There's not enough information to say what's going wrong. Set a breakpoint in openAd, which you can do in firebug or with the debugger statement. Make sure that the built-in pop-up blocker and no extension (e.g. any adblocker) is preventing the new window or tab from opening. Commented Dec 10, 2011 at 23:29

2 Answers 2

2

I have went to your page in Opera 11.60 and called openAd('/Ads/MMA_Front_Page.com', 'http://www.anrdoezrs.net/click-4706163-10919130'); through Dragonfly and the information was displayed in my browser that the popup has been blocked. When I click to display the popup anyway, the new windows with your add target is displayed correctly.

Thus, I would suggest to seek different method to open the ad or accept the fact you may be blocked by popup / ad blocker.

answered Dec 10, 2011 at 23:25
Sign up to request clarification or add additional context in comments.

3 Comments

I guess a regular link is in order? I didn't know it countet as a popup.
Calling window.open != regular link.
Yea i know, i just used regular href
2

if your problem is that the browser loads the url in the href as well as opens a new window then you need to add return false as so:

onclick="openAd('/Ads/MMA_Front_Page.com', 'http://www.anrdoezrs.net/click-4706163-10919130'); return false;"
answered Dec 10, 2011 at 23:31

1 Comment

Thanks, didn't know i had to place it there.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.