1. Tuyển Mod quản lý diễn đàn. Các thành viên xem chi tiết tại đây

POP UP?

Chủ đề trong 'Hỏi đáp Tin học' bởi anhxp, 15/02/2003.

  1. 1 người đang xem box này (Thành viên: 0, Khách: 1)
  1. anhxp

    anhxp Thành viên tích cực

    Tham gia ngày:
    05/12/2001
    Bài viết:
    203
    Đã được thích:
    1
    Làm sao tạo được 1 pop up cho trang web của mình và cái pop up nayd tự biến đi trong 10 s

    anhxp
  2. iso9002

    iso9002 Thành viên tích cực

    Tham gia ngày:
    15/12/2001
    Bài viết:
    521
    Đã được thích:
    6
    Khó lắm!
    ISO
  3. mebongda

    mebongda Thành viên mới

    Tham gia ngày:
    24/12/2002
    Bài viết:
    941
    Đã được thích:
    0
    Đây nè bác
    ==========================================
    Script: Automatic Timed Self-Closing Popup Window
    Function: Opens a window that will close itself after a
    pre-set time. The popup can be launched from
    a link in your page, or automatically when the
    launching page loads. Very well behaved, and
    does not launch multiple windows on re-clicks.

    Browsers: All browsers
    Author: etLux
    ==================================
    General Notes:
    There are two short scripts. One launches the popup window
    and goes in the page that will launch it. The other goes
    in the window that is opened.
    ============================================
    Step 1. The Launching Page Code
    Put the following script in the <head> ... </head> part of
    the launching page. Set theURL to that of the page to be
    launched. The width and height variables set the size of
    the launched window.
    Be careful to get the entire long line...
    newWindow = window.open(...);
    on a single line in your page, since spaces or linebreaks
    will cause this to fail, otherwise.
    You can set which features are active in the popup window
    (toolbar, menubar, resizable, scrollbars, status, location)
    by changing the word no to yes for each of the associated
    variables in the window.open() call.
    Here is the script...
    <script>
    // (C) 2001 www.CodeLifter.com
    // http://www.codelifter.com
    // Free for all users, but leave in this header
    var theURL = 'thePopupPage.html';
    var width = 300;
    var height = 400;
    function popWindow() {
    newWindow = window.open(theURL,'newWindow','toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no,width='+width+',height='+height);
    }
    </script>
    Launching the Popup Window...
    To launch the popup from a link put this in your page where
    you want the launching link to appear:
    <a href="javascript:PopWindow()">Click here</a>
    Another popular usage is to launch the popup window when
    the launching page is entered. You can do this by calling
    the function in the <body> tag, like this:
    <body onload="popWindow()">
    ============================================
    Step 2. The Popup Window Code
    This code must go in the <head> ... </head> part of the
    window that is launched (in theURL variable, above). The
    time for the window to remain open is set with the variable
    howlong, in milliseconds (that is, var howlong = 10000 would
    keep the window open ten seconds after it loads.
    <script>
    // (C) 2001 www.CodeLifter.com
    // http://www.codelifter.com
    // Free for all users, but leave in this header
    var howLong = 10000;
    t = null;
    function closeMe(){
    t = setTimeout("self.close()",howLong);
    }
    </script>
    IMPORTANT
    You must *also* call the function in the <body> tag of the
    popup window, like this:
    <body onload="closeMe();self.focus()">
    Note the use of self.focus(), which brings the popup to
    the front when it loads.
    ==============================================
    Ad***ional Notes:
    If you want to put a self-close link in the popup window,
    it is done like this:
    <a href="javascript:self.close()">click here</a>
    ======================================
  4. mebongda

    mebongda Thành viên mới

    Tham gia ngày:
    24/12/2002
    Bài viết:
    941
    Đã được thích:
    0
    Nói tóm lại thì bác chỉ cần để cái script này vô cái trang mà bác popup
    <html>
    <head>
    <script>
    // (C) 2001 www.CodeLifter.com
    // http://www.codelifter.com
    // Free for all users, but leave in this header
    var howLong = 10000;
    t = null;
    function closeMe(){
    t = setTimeout("self.close()",howLong);
    }
    </script>
    </head>
    <body onLoad="closeMe();self.focus()">
    </html>
  5. anhxp

    anhxp Thành viên tích cực

    Tham gia ngày:
    05/12/2001
    Bài viết:
    203
    Đã được thích:
    1
    Xin cảm ơn.
    anhxp

Chia sẻ trang này