admin管理员组

文章数量:1415475

I can not open local file ,meanwhile i use "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --allow-file-access-from-files on my shortcut of my google chrome. the explorer tips the security mode had been closed and I can open a new window using js or href attribute. But the question is :why each time I click the href ,it always open a blank page and nothing to display.so..

function copyUrl(obj)
{
var href = $(obj).attr("hreff");
var hideInput = $("#hidInputHref");
hideInput.val(href);
hideInput.select();
try
{
    document.execCommand('copy');
    var opener = window.open('file:////C:/windows');
   // opener.document.write("<iframe src='c:\' width='100%' height='100%'></iframe>");
    //var test = "<body><script>" +
    //    "alert(1);console.log(1);"
    //"<" + "\/script><div>11111111111</div></body>";

    ////var stateObj = { foo: "bar" };

    //opener.document.write(test);

    //opener.history.pushState("", "page 2", "./a.html");
    //opener.location.href = "www.baidu";
    //opener.location.reload();

    opener.opener.location.href = "C:\windows";

}
catch (err)
{
    console.log(err);
}

}

C# code:

partsQueryList[i].ImageRefLink = "<a onclick='copyUrl(this)' hreff='" + "C:\\" + "' ><font color='blue'>ImageRefLink</font></a>";

btw,when I tried to use pushSate method ,it can push a new url to new window,but It can not solve crossdomain issue.so...how could I solve it?thanks!

I can not open local file ,meanwhile i use "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --allow-file-access-from-files on my shortcut of my google chrome. the explorer tips the security mode had been closed and I can open a new window using js or href attribute. But the question is :why each time I click the href ,it always open a blank page and nothing to display.so..

function copyUrl(obj)
{
var href = $(obj).attr("hreff");
var hideInput = $("#hidInputHref");
hideInput.val(href);
hideInput.select();
try
{
    document.execCommand('copy');
    var opener = window.open('file:////C:/windows');
   // opener.document.write("<iframe src='c:\' width='100%' height='100%'></iframe>");
    //var test = "<body><script>" +
    //    "alert(1);console.log(1);"
    //"<" + "\/script><div>11111111111</div></body>";

    ////var stateObj = { foo: "bar" };

    //opener.document.write(test);

    //opener.history.pushState("", "page 2", "./a.html");
    //opener.location.href = "www.baidu.";
    //opener.location.reload();

    opener.opener.location.href = "C:\windows";

}
catch (err)
{
    console.log(err);
}

}

C# code:

partsQueryList[i].ImageRefLink = "<a onclick='copyUrl(this)' hreff='" + "C:\\" + "' ><font color='blue'>ImageRefLink</font></a>";

btw,when I tried to use pushSate method ,it can push a new url to new window,but It can not solve crossdomain issue.so...how could I solve it?thanks!

Share Improve this question asked Dec 10, 2015 at 3:36 MapleStoryMapleStory 6684 gold badges11 silver badges24 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 1

You have 4 slashes instead of 3. Try this :

var opener = window.open('file:///C:/windows');

Note: Also C:/windows doesn't seem like a valid file. Try with a valid file name.

Check this post for more help : Open a local HTML file using window.open in Chrome

本文标签: javascriptjsWindowopen() for trying to open local folder failedStack Overflow