想在php的window.open页面中打开链接url

时间:2017-09-11 10:55:15

标签: javascript php

我想在window.open页面打开我的链接页面。我将我的网址保存在一个变量中,并在href链接中传递该变量。

这是我的链接

<?php $linkvalue = "../mod/scorm/player.php?a=".$row->instance."&currentorg=".$orgidentifier."&scoi‌​d=".$scoid."&sesskey=".$_SESSION['USER']->sesskey."&display=popup&mode=normal"; ?>

我就像这样使用

<a class="btn btn-primary btn-xs" href="<?php echo $linkvalue; ?>">LAUNCH</a>

我想使用window.open

打开上面的链接

任何人都可以帮助我如何做到这一点..

提前致谢..

3 个答案:

答案 0 :(得分:0)

这应该这样做:

<a class="btn btn-primary btn-xs" href="javascript:window.open('<?php echo $linkvalue; ?>');">LAUNCH</a>

您还可以在链接上设置目标属性_blank,它将在新窗口中打开它。

答案 1 :(得分:0)

不要使用JavaScript(window.open),请保持简单并使用target属性。

target
    Specifies where to display the linked URL. It is a name of, or keyword for, a browsing context: a tab, window, or <iframe>. The following keywords have special meanings:

    _self: Load the URL into the same browsing context as the current one. This is the default behavior.
    _blank: Load the URL into a new browsing context. This is usually a tab, but users can configure browsers to use new windows instead.
    _parent: Load the URL into the parent browsing context of the current one. If there is no parent, this behaves the same way as _self.
    _top: Load the URL into the top-level browsing context (that is, the "highest" browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this behaves the same way as _self.

答案 2 :(得分:0)

我得到了解决方案

如果我们这样使用它会工作..在同一个标​​签中打开新窗口上的链接..

<a class="btn btn-primary btn-xs" onclick="window.open('<?php echo $linkvalue; ?>', 'mywindow', 'location=0,status=0,scrollbars=0,width=1000,height=600');">LAUNCH</a>