-2

undefined に移動してから test.com に移動します。

http://url.com、次にhttp://test.com 、次にhttp://anotherdesiredurl.comに移動するにはどうすればよいですか

<head>

<script type="text/javascript">
        <!--
        function popup(url) {

            var width = 300;
            var height = 200;
            var left = (screen.width - width) / 2;
            var top = (screen.height - height) / 2;
            var params = 'width=' + width + ', height=' + height;
            params += ', top=' + top + ', left=' + left;
            params += ', directories=no';
            params += ', location=no';
            params += ', menubar=no';
            params += ', resizable=no';
            params += ', scrollbars=no';
            params += ', status=no';
            params += ', toolbar=no';
            newwin = window.open(url, 'popup', 'params');
            if (window.focus) {
                newwin.focus()
            }

            return false;

        }
setTimeout(function() {popup('http://www.test.com/'); }, 8000)


        //-->
        //]]>
    </script>


<head>
<body>
<input type="button" value="Click Blitch" onclick="popup();"/>
</body>
4

3 に答える 3

1

あなたが書いた

newwin = window.open(url, 'popup', 'params');

私は期待していたでしょう:

newwin = window.open(url, 'popup', params);

しかし、それがあなたのpbに関連しているかどうかはわかりません

于 2012-07-24T07:59:45.680 に答える
0

popupここでは関数に引数を渡していないため:

<input type="button" value="Click Blitch" onclick="popup();"/>

引数を渡すか、未定義の場合は関数をチェックインしてから、いくつかの URL を割り当てる必要があります

于 2012-07-24T07:57:32.940 に答える
0

これを試して:

JavaScript

function popup(url) {

    var width = 300;
    var height = 200;
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width=' + width + ', height=' + height;          
    params += ', top=' + top + ', left=' + left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=no';
    params += ', scrollbars=no';
    params += ', status=no';
    params += ', toolbar=no';
    newwin = window.open(url, 'popup', 'params');
    if (window.focus) {
      newwin.focus()
    }

    return false;

  }

  function openWindows() {
    popup('http://url.com');
    popup('http://text.com');
    popup('http://http://anotherdesiredurl.com');
  }

HTML

<input type="button" value="Click here" onclick="openWindows();"/>

タイムアウト後に同じポップアップの場所を変更したい場合は、JavaScript を次のように変更できます。

  function popup(url, win) {

    var width = 300;
    var height = 200;
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width=' + width + ', height=' + height;
    var newwin = win;
    params += ', top=' + top + ', left=' + left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=no';
    params += ', scrollbars=no';
    params += ', status=no';
    params += ', toolbar=no';
    if (newwin) {
      newwin.location = url;
    } else {
        newwin = window.open(url, 'popup', 'params');
    }
    if (window.focus) {
      newwin.focus()
    }

    return newwin;

  }

  function openWindows() {
    var win = popup('http://url.com');
    setTimeout(function () {
        popup('http://text.com', win);
    }, 2000);
    setTimeout(function () {
        popup('http://http://anotherdesiredurl.com', win);
    }, 4000);
  }
于 2012-07-24T08:01:32.857 に答える