简体   繁体   English

我可以从外部文件加载 Web 路径吗

[英]Can I load a web path from an external file

I have an application thats uses HTML5 and there are many html pages that point to the same url, however, the url can change.我有一个使用 HTML5 的应用程序,并且有许多指向相同 url 的 html 页面,但是,该 url 可以更改。

Is there a way that rather than pointing each individual html page to a url, that i can point them to a single file that contains a url, therefore only having to change the url from one location and individually?有没有一种方法,而不是将每个单独的 html 页面指向一个 url,我可以将它们指向一个包含 url 的单个文件,因此只需要从一个位置单独更改 url?

IE 10 pages contain an iframe with src="http://www.google.co.uk" if I now wanted them to point to "http://www.yahoo.co.uk" I'd have to make that change 10 times instead of once. IE 10 页面包含一个带有 src="http://www.google.co.uk" 的 iframe,如果我现在想让它们指向“http://www.yahoo.co.uk”,我必须这样做更改 10 次而不是一次。 Could i create some kind of file so that src="webpath" instead?我可以创建某种文件,以便 src="webpath" 代替吗?

You can use an external javascript file which will be used in all the ten pages and you , just, can edit the javascript file to load the same iframe in all the ten pages.您可以使用将在所有十个页面中使用的外部javascript文件,并且您可以编辑javascript文件以在所有十个页面中加载相同的iframe

All the 10 pages :所有 10 页

 <script src="iframe-location.js"></script> <body onload="loadIframe()"> <iframe id="frame"></iframe> </body>

iframe-location.js (External js file): iframe-location.js (外部js文件):

 //You just can change the iframe src function loadIframe() { document.getElementById("frame").src = "https://bing.com"; }

You can use redirection using javascript您可以使用 javascript 使用重定向

Create a resource that will be used by the 10 pages and that page will have the redirection创建一个将由 10 个页面使用的资源,该页面将具有重定向

window.location.replace("http://www.yahoo.com");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM