English 中文(简体)
与Greasemonkey的封闭窗口
原标题:Closing windows with Greasemonkey

我先是写一本用于“Facebook”的“Greasemonkey”字。 我知道,Greasemonkey被 sand为沙子,而且至少从远到现在,除非你改变浏览器的一个环境,否则你不能把窗户关闭。 然而,我知道,大多数浏览器允许儿童窗户关闭,无需用户确认。 我试图拿我的文字打开窗户,从一个超文本物体中 gr取一个正文片,把窗户关在一页子的报刊上。

我的窗口开放守则就是这样:

function birthday(linkAddress) {
var winNew=window.open(linkAddress, "_blank", "height=100", "width=100");
/*code to be run on page*/
    winNew.close()
}

窗户开了罚款,但在 Chrome语中,我发现一滴script字错误,即“不能把方法贴近未界定”。 我假设,我的物体与Greasemonkey沙箱有关,有点错,但我会错失确定什么。 是否甚至有可能在 Chrome用Greasemonkey script关闭窗户? 是否有某种情况我需要帮助? 或者,我的法典错了吗? 牢记这一守则是从我用一顿一号记号在Click活动上写到该页的纸面上规定的功能。 如果在儿童网页上查阅DOM要素,也将受到欢迎。

感谢任何帮助!

(我的经历是首次撰写一份Greasemonkey书)

最佳回答

贴出的编码单不够充分,与“把窗户放在一页子的报纸上”的宣称操作不相称。

因此,最好的猜测是,闭关功能要么在<条码>旁边(<>/条码>上”(其中界定了<条码>,新),要么在未载明的法典中造成问题。

另一项警告是,你需要知道,Greasemonkey的文字也可能向儿童窗户开火——这取决于是否在打开儿童窗户时具体说明了URL。

Here is sample code that opens and closes a child window at the push of buttons:
See it in action at jsfiddle.

<html>
<head>
<script type="text/javascript">
    var chldWnd;

    function OpenChldWin ()
    {
        //chldWnd = window.open ("http://www.google.com");
        chldWnd = window.open (  ,  , height=200, width=200 );
        chldWnd.document.write ( <p>My New Window</p> );    //-- Don t do if opening a URL in new window.
        chldWnd.focus();
    }

    function CloseChldWin ()
    {
        if (chldWnd.closed)
            alert ( Child window was already closed. );
        else
        {
            chldWnd.close ();
            alert ( Child window is NOW closed. );
        }
    }
</script>
</head>
<body>
<input type="button" value="Open Child Window"      onclick="OpenChldWin ()">
<input type="button" value="Close the Child Window" onclick="CloseChldWin ()">
</body>
</html>
问题回答

暂无回答




相关问题
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.

热门标签