我想编写一个简单的脚本来打开网站并调用链接的.js文件中的函数。
更准确地说,我要打开SharePoint,调用用于在Windows资源管理器中打开文件夹并再次关闭网站的功能。 由于某些原因,除非在活动的Windows会话中至少以这种方式完成一次操作,否则我可能无法直接在资源管理器中打开该文件夹...
我该怎么办?
到目前为止,我尝试了以下操作:
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");');
答案 0 :(得分:1)
您可以包含带有外部网站路径的脚本
<script type="text/javascript" src="http://www.external.com/script.js"></script>