-2

我正在创建一个用户点击链接的网页,新网站将在新窗口中打开

例子

echo "<a href='www.google.com' target='_blank'>Click Here</a>";

如果我单击此链接,站点将在根链接(localhost/mysite/www.google.com)中打开,而不是 www.google.com

4

4 回答 4

1

协议无关版本:

<a href='//something/test/and/rest' target='_blank'>Click Here</a>

//将正常http://工作https://

于 2013-02-20T11:32:47.173 回答
1
<a href='http://www.google.com' target='_blank'>Click Here</a>

http://在您的链接之前添加

于 2013-02-20T11:30:05.967 回答
0

尝试

echo "<a href='http://www.google.com' target='_blank'>Click Here</a>";

您必须拥有http://https://因为没有它,浏览器认为它是具有相同域的同一页面。

因此,您需要告诉浏览器发送其他http request内容,而不是将其添加到同一域中。

于 2013-02-20T11:31:06.247 回答
0

要在 html 中创建将在新窗口中打开的链接:

<a href="http://example.com" target="_blank">Click Me</a>

对于 PHP,回显字符串并使用反斜杠转义双引号(如果您使用它们而不是单引号):

echo "<a href=\"http://example.com\" target=\"_blank\">Click Me</a>";
于 2013-02-20T11:37:29.520 回答