Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When we visit the website there should be open a popup window on right side.

What I have tried:

I had tried but it open at every refresh page.
Posted
Updated 8-Feb-17 4:13am

1 solution

You'll need to remember whether the user has already visited the site, and only show the message if they haven't.

If your server-side code needs to know whether it's the user's first visit, you'll need to use a cookie[^].

If you only need to know from Javascript, then use local storage:
Window.localStorage - Web APIs | MDN[^]
Local Storage And How To Use It On Websites – Smashing Magazine[^]


However, if you're trying to open a new browser window (window.open[^]) automatically when the page loads, that will not work. Your popup will be blocked by the popup blocker built in to every major browser. Instead, you'll need to show your message within the page, using something like jQuery UI's Dialog[^] or Bootstrap's Modal[^].
 
Share this answer
 
Comments
Arpita Itankar 8-Feb-17 12:52pm    
i want to add popup window, to show active events in my website, so what i should do sir?
Richard Deeming 8-Feb-17 13:07pm    
You can't. As I explained in my answer, any popup window which tries to open automatically will be blocked by the popup blocker built in to all major browsers.

If there was a way around that, every advertising network would use it, and we would be back to the bad old days of sites launching hundreds of popup adverts every time you opened them.

Your only option is to display the message within the page - again, as I explained in my answer.
Arpita Itankar 9-Feb-17 0:20am    
k sir please send me example with source code bcs i m confused

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900