Html 将 wix 网站页面重定向到外部 URL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30698032/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 11:36:24  来源:igfitidea点击:

Redirect a wix website page to external URL

html

提问by ASM

I'm trying to create a wix page which will redirect all users that link to it to an external URL.

我正在尝试创建一个 wix 页面,该页面会将链接到它的所有用户重定向到外部 URL。

I tried adding the code below as a "html wix app" but it didn't worked.

我尝试将下面的代码添加为“html wix 应用程序”,但没有奏效。

<meta http-equiv="refresh" content="0; URL=http://www.my-new-url.com">

回答by Anke

I had a similar use case and solved it using the wix-location module:

我有一个类似的用例并使用 wix-location 模块解决了它:

import wixLocation from 'wix-location'; 

$w.onReady(function () {
     wixLocation.to("http://www.my-new-url.com");
}) 

回答by Stephen Saucier

When you insert an HTML "module" into Wix, it is actually inserted into an iframe on the page rather than the page itself.

当您将 HTML“模块”插入 Wix 时,它实际上是插入到页面上的 iframe 而不是页面本身。

Fortunately, the iframe is hosted at the same domain, so you don't have to deal with cross-domain issues. Therefore, this code, when inserted into an HTML module on a Wix page, successfully redirects the parent:

幸运的是,iframe 托管在同一个域中,因此您不必处理跨域问题。因此,这段代码在插入到 Wix 页面上的 HTML 模块时,成功地重定向了父级:

<script type="text/javascript">
    window.parent.location.href = "http://www.my-new-url.com"
</script>

回答by Prince

Maybe try:

也许尝试:

<meta http-equiv="refresh" content="0; URL=http://www.my-new-url.com/" />

You left out a " at the end. I hope this helps!

你最后遗漏了一个“。我希望这会有所帮助!

Try:

尝试:

<script type="text/javascript">
    window.location.href = "http://www.my-new-url.com"
</script>

Try this:

尝试这个:

<html>
<meta http-equiv="refresh" content="0; URL=http://www.my-new-url.com/" />
</html>

回答by saji89

You can use wix-locationfrom Wix Code, for this. An example of using it to navigate to an external URL is:

您可以使用WiX的地点维克斯的代码,这一点。使用它导航到外部 URL 的示例是:

import wixLocation from 'wix-location';

// ...

wixLocation.to("http://www.my-new-url.com");

回答by lemon

The above code:

上面的代码:

<script type="text/javascript">
    window.parent.location.href = "http://www.my-new-url.com"
</script>

works on my wix site: https://www.lemon-sin.com.au/redirects to director's linkedin account

在我的 wix 网站上工作:https: //www.lemon-sin.com.au/重定向到导演的linkedin 帐户