View Full Version : need help with basic javascript programming

01-18-2012, 02:15 AM
Hi so i am using onClick="myPopup(); on a button and when someone clicks on the button, it pops up an advertisement in a new tab.

But is there a way to make the users stay on the page where the button is located instead of forcing the browser to automatically switch to the advertisement tab when a button is clicked?

01-18-2012, 03:22 AM

01-18-2012, 03:44 AM

Thanks for the reply but it didn't work D: I tried with your code but my page redirects to the advertisement.

You know how when you middleclick a link, the page of the link displays in a new tab but you still stay in the same page where the link is? I want this to happen when a user clicks with a left mouse button.

1.User clicks on the button
2.The advertisement shows on another tab
3.User still stays on the same page

01-18-2012, 04:12 AM

This will open the url in either a new tab or a new window. There is nothing you can do to determine whether the page opens in a new tab or new window, though, that depends on the browser and the user's settings.

01-18-2012, 07:43 AM
Which of the three places web pages open is completely under the browser's owner's control. You can only suggest where it should open in your code and the browser can be set to ignore your suggestion and open it where the browser owner wants it to open.

For example I have my browser configured so that all pages on the same site open in the same tab replacing one another and all pages from a new site open a new tab - regardless of how the web page is coded.