-1

i want to open my link page in window.open page..i kept my url in one variable and i pass that variable in href link..

here is my link

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

And i used like this

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

i want to open the above link using window.open

can anyone help me how to do that..

Thanks in advance..

user200
  • 291
  • 1
  • 4
  • 21
  • I am having trouble understanding the exact requirement (even after reading the comments) – GKK Sep 11 '17 at 11:59

3 Answers3

0

This should do it:

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

You can also set the target attribute on the link to _blank which will open it in a new window.

Ashley
  • 1,459
  • 2
  • 12
  • 25
  • no i dont want to open in new window..i want to open new window on the same tab..like popup – user200 Sep 11 '17 at 11:01
  • @user200 Then you need to look at a JS solution that allows you to load iframes inside modal windows. – Ashley Sep 11 '17 at 11:02
  • @user200 this looks like a good starting point: https://stackoverflow.com/questions/25565716/load-iframe-in-bootstrap-modal – Ashley Sep 11 '17 at 11:07
  • @user200 Then you need to make your question more clear, as it states you want to use window.open which has been provided. If you need something else, you need to explain what in the original post. – Ashley Sep 11 '17 at 11:17
0

Rather than using JavaScript (window.open), keep things simple and make use of the target property.

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.
Script47
  • 14,230
  • 4
  • 45
  • 66
  • i tried all 4...still it showing the link in new window – user200 Sep 11 '17 at 11:04
  • @user200 yes, that is exactly what you asked for in your question, you mentioned `window.open` and that is what `window.open` does. Clarify your question. – Script47 Sep 11 '17 at 11:05
0

i got the solution

if we use like this it will work..it open the link on the new window in the sametab..

<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> 
user200
  • 291
  • 1
  • 4
  • 21