Santosh
Santosh

Reputation: 2495

How to open a url link as a popup screen

I have an url, lets say www.myurl.com/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.

Upvotes: 4

Views: 68403

Answers (3)

Santosh
Santosh

Reputation: 2495

just 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.com", "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.

Upvotes: 7

sms247
sms247

Reputation: 4504

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.com/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>

Upvotes: -1

Drakes
Drakes

Reputation: 23660

No, there is no such function without user interaction


You could create a dialog() widget with jQuery, however.

See: https://blog.udemy.com/jquery-popup-window/

Demo: http://jsbin.com/yusenu/2/

Upvotes: 0

Related Questions