Find the answer to your Linux question:
Results 1 to 3 of 3
As the title says, I need a script that prompts a user before loading a website, preferrably written in PHP with a combination of Javascript. When a website or .php ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2014
    Posts
    9

    Javascript/PHP script that prompts a user before loading website


    As the title says, I need a script that prompts a user before loading a website, preferrably written in PHP with a combination of Javascript.

    When a website or .php site is loaded, it will prompt the user with a confirmation box, using windows.confirm( ), that displays "You agree that continuing.....", with an OK and Cancel buttons.

    Pressing OK will continue loading the site's content and at the same time load a new website on a new tab, using window.open( ).

    Pressing Cancel will just close the current window, or specifically the current tab.

    No problem on Cancel and opening a new window. My problem is how to prevent the page from loading until OK button is pressed.

  2. #2
    Just Joined!
    Join Date
    Jan 2014
    Posts
    9
    I've solved my own problem. Placing the javascript above all others on the heading.
    Code:
    <script type="text/javascript">
    var answer = confirm ("Please click on OK to continue loading this page or CANCEL to close it.")
    	if (answer)
    	{
    		window.open("URL") ;
    	}
    	else
    	{
    		window.close ( ) ;
    	}	
    </script>
    But the problem is, the window.open is blocked by popup blocker.
    How do I execute window.open without being blocked by a popup blocker?
    Popup blocker will automatically blocked an automated popup but mine is not automated, its from a confirmation box.
    Is there any other way to use window.open without getting blocked?

  3. #3
    Just Joined! KenWeiLL's Avatar
    Join Date
    Jan 2014
    Location
    Philippines
    Posts
    10
    Quote Originally Posted by Siquijor View Post
    I've solved my own problem. Placing the javascript above all others on the heading.
    But the problem is, the window.open is blocked by popup blocker.
    How do I execute window.open without being blocked by a popup blocker?
    Popup blocker will automatically blocked an automated popup but mine is not automated, its from a confirmation box.
    Is there any other way to use window.open without getting blocked?
    I have the same problem. But it's probably due to browser incompatibilities.

    Double window.open works on Firefox but not working on IE and Chrome. On IE and Chrome, only the first window.open gets executed while the other one will be blocked by their popup blocker. On Firefox, it works like a charm.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •