Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

The 1st edition of the Target Community Lens newsletter is out now! Click to the right to find all the latest updates
SOLVED

Opening affiliate banners in a new window

Avatar

Level 1

Hi All,

On my website i feature affiliate banners, when I click these banners it does not open a new window (i.e. it takes the user away from the page that they are on).

How can I make sure that when a user clicks on a banner on my website, it opens a new window?

Thanks guys. 

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi , 

Please make sure that you use "window.open()" function of javascript on click of the banner. Here is the sample code for the same. 

<!DOCTYPE html> <html> <body> <p>Click the button to open a new browser window.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { window.open("http://www.w3schools.com"); } </script> </body> </html>

Thanks & Regards

Parit Mittal

1 Reply

Avatar

Correct answer by
Level 10

Hi , 

Please make sure that you use "window.open()" function of javascript on click of the banner. Here is the sample code for the same. 

<!DOCTYPE html> <html> <body> <p>Click the button to open a new browser window.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { window.open("http://www.w3schools.com"); } </script> </body> </html>

Thanks & Regards

Parit Mittal