javascript - js:Window.open() for trying to open local folder failed - Stack Overflow

I can not open local file ,meanwhile i use "C:Program Files (x86)GoogleChromeApplicationchrom

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745191430a4615880.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信