I have an url, lets say www.myurl/mywebpage
and when I type this url in browser it opens my page and everything works fine.
Now my requirement is that when I type this url in browser,the webpage should open like a pop up.
As there is no button click or such event, I cannot write window.open
javascript function to open this as pop up.
Is there any other way(jquery) or how we can use window.open function to show my page as popup when the url is hit in the browser.
Thanks in advance.
I have an url, lets say www.myurl./mywebpage
and when I type this url in browser it opens my page and everything works fine.
Now my requirement is that when I type this url in browser,the webpage should open like a pop up.
As there is no button click or such event, I cannot write window.open
javascript function to open this as pop up.
Is there any other way(jquery) or how we can use window.open function to show my page as popup when the url is hit in the browser.
Thanks in advance.
Share Improve this question edited May 22, 2015 at 6:24 captainsac 2,4903 gold badges28 silver badges51 bronze badges asked May 22, 2015 at 5:51 SantoshSantosh 2,50511 gold badges42 silver badges67 bronze badges 3- 1 If you were designing a car, would you swap the accelerator and brake pedals? Deliberately attempting to override the standard & expected behaviour of a website is a terrible, terrible, terrible usability mistake. People will expect to open your website like every other website. Don't try and make it do something different. – Christian Commented May 22, 2015 at 6:02
- i agree.But we can make user feel that it opens as pop up..If there is nothing different in making then nothing new es. – Santosh Commented May 22, 2015 at 6:10
- In general I agree with Varga but innovation is, by definition, changing the "standard & expected behavior" of something, and not all innovation is bad. Use popups wisely and thoughtfully.Most of all don't make the user experience dependent on them. – davea0511 Commented Sep 3, 2019 at 16:22
3 Answers
Reset to default 7just using window.open(with out any function) in html solved my problem.
in page1.html i wrote the following script
<script>
window.open("http://google.", "myWindow", 'width=800,height=600');
window.close();
</script>
When i type page1.html in browser address,it opens google page as a popup.
Thanks everyone for your efforts in trying to help me.
No, there is no such function without user interaction
You could create a dialog()
widget with jQuery, however.
See: https://blog.udemy./jquery-popup-window/
Demo: http://jsbin./yusenu/2/
try this code: (popupex.html will replace with your page url)
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>click demo</title>
<script src="https://code.jquery./jquery-1.10.2.js"></script>
</head>
<body>
<a href="popupex.html" onclick="return popitup('popupex.html')"
>Link to popup</a>
<script>
function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
if (window.focus) {newwindow.focus()}
return false;
}
</script>
</body>
</html>