我想编写一个简单的脚本来打开网站并调用属于链接 .js 文件一部分的函数。
更准确地说,我想打开一个SharePoint,调用用于在Windows资源管理器中打开文件夹的函数,然后再次关闭网站。 由于某种原因,我可能无法直接在资源管理器中打开该文件夹,除非我在事件窗口 session 期间至少这样做过一次...
我该怎么做?
到目前为止,我尝试了以下方法:
var IE = new ActiveXObject("InternetExplorer.Application");
var WSH = new ActiveXObject("WScript.Shell");
IE.visible = true;
IE.navigate("https://mysharepoint.com/Folder");
WSH.PopUp("Click to fire function");
//the following line throws an error, because the function is unknown...
IE.Document.defaultView.setTimeout(NavigateHttpFolder, 0, "https://mysharepoint.com/Folder", "_blank");
//the following line does not throw an error, but nothing happens either..
IE.Document.defaultView.setTimeout(function(){NavigateHttpFolder("https://mysharepoint.com/Folder", "_blank");}, 0);
但是,当我打开 Sharepoint 并在地址栏中键入以下行时,它完全达到了我想要的目的,并且打开了文件夹...
javascript:NavigateHttpFolder("https://mysharepoint.com/Folder", "_blank");
你能帮我一下吗?我根本找不到让它发挥作用的方法。
更新:现在它突然起作用了!我之前尝试过以下方式,但直到现在它没有做任何事情(???)...
IE.Navigate('javascript:NavigateHttpFolder("https://mysharepoint.com/Folder", "_blank");');
最佳答案
您可以包含带有外部网站路径的脚本
<script type="text/javascript" src="http://www.external.com/script.js"></script>
关于Javascript:如何调用外部网站的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55264387/