English 中文(简体)
Javascript: 2. 同一领域开放的专用浏览器窗口
原标题:Javascript: Find browser windows open with the same domain

如果所有露天浏览器窗户都与试图获得名单的窗户相同,则是否有办法获得一份名单?

问题回答

总的来说,第2号。

除非窗户之间有“连接”(例如,一个窗口使用<条码>窗口>开放/代码>打开所有其他窗口),否则浏览器窗户因安全原因可以进行交流。

<><>Edit>:

如果你给你的窗户分配一个名字,你可以在更新母子之后重新控制。

  1. www.un.org/Depts/DGACM/index_spanish.htm Var = 窗口.open(一些Page.html,WergeName ); 开放儿童窗口,名称为windowName

  2. After refreshing the parent page, windowVar = window.open( , windowName ); re-associates the variable windowVar with the window of name windowName.

  3. 现在,windowVar.place.href=logout.html>;请您登录用户。

<><>Edit>:

Assuming you use PHP, you could do something like this:

Create logged.php with a function logged_in that verifies if the session ID is still valid.

<?php
    if (isset($_GET[ sid ]))
            if (logged_in($_GET[ sid ]))
            echo "in";
    else
            echo "out";
?>

在您的网页中列入<编码>check()。

function check()
{
    var url = "http://redtwitz.com/test/logged.php?sid=" + sessionId;
    var request;
    try
    {
        request = new XMLHttpRequest();
    }
    catch(error1)
    {
        try
        {
            request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(error2)
        {
            request = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    request.open("GET", url, false);
    request.setRequestHeader("User-Agent",navigator.userAgent);
    request.send(null);
    if(request.status==200)
        if(request.responseText == "out")
            window.location.href = "logout.html";
}

电话检查每5秒进行。

<body onload="setInterval(check, 5000);">

Alternatively, you can implement Chrome extension and do your task by using extension api: http://code.google.com/chrome/extensions/tabs.html But it will work in Chrome browser only.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签