Results 1 to 7 of 7

Thread: Go to URL instead of dialog box

  1. #1
    Join Date
    Sep 2005
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Go to URL instead of dialog box

    Greetings,

    I am playing around with an alarm script, see:

    Code:
    <script>
    var alarmTimer = null;
    var alarmSet;
    function setAlarm()   { alarmSet = true;  }
    function clearAlarm() { alarmSet = false; }
    function initAlarm() {
      if (alarmTimer!=null)clearInterval(alarmTimer);
      var nowTime = new Date();
      clearAlarm();
      document.exf1.h.value = nowTime.getHours();
      document.exf1.m.value = nowTime.getMinutes();
      document.exf1.s.value = nowTime.getSeconds();
      alarmTimer=setInterval("countTime()",1000);
    }
    function matchH() { return (document.exf1.ch.value == document.exf1.h.value); }
    function matchM() { return (document.exf1.cm.value == document.exf1.m.value); }
    function matchS() { return (document.exf1.cs.value == document.exf1.s.value); }
    function countTime() {
      var nowTime = new Date();
      document.exf1.ch.value = nowTime.getHours();
      document.exf1.cm.value = nowTime.getMinutes();
      document.exf1.cs.value = nowTime.getSeconds();
      if (matchH() && matchM() && matchS()) {
        alert("ALARM!");
      }
    }
    onload=initAlarm;
    </script>
    But I would rather a pop-up window (HTML) appear than a dialog box, is this possible?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Of course. Replace:
    Code:
        alert("ALARM!");
    With:
    Code:
        window.open("popuppage.html");
    However, some popup blockers may stop this. Just a warning.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Sep 2005
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Definitely not much of a challenge for you, Twey!

    Thank you!

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Here's a question I've never gotten around to asking.

    Popup blockers block anything that is automatically generated.

    However, some don't block popups when you click on a link.

    Why is this, and could it relate to the above situation?

    Do the popup blockers check if the user DID something to make it happen?

    Or... what?

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Do the popup blockers check if the user DID something to make it happen?
    Exactly right.
    Most good popup blockers will, on encountering a window.open() call, go up through the stack trace until they hit user input which is unfakeable by Javascript: the native code that calls the onclick() or onsubmit() functions, for example. If they leave the webpage code and get to a certain point up the native stack trace (browser dependent), they will know that it hasn't been fired by deliberate user input, and block the call.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Sep 2005
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am having trouble defining the size of the window (don't want it to be fullscreen, chromeless would be ideal).

    Code:
        window.open("page1.htm", "height=200,width=300");
    doesn't work at all, any clue?

    Any additional parameters I specify don't work at all.

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Before specifying the features of the window, you must give it a second parameter, which is its name.
    Code:
        window.open("page1.htm", "countdownwindow", "height=200,width=300");
    Real chromeless windows are impossible, though they can be faked with something like the DHTML Window script here on DD.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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