AL MaMun
AL MaMun

Reputation: 63

How write a javascript variable in window.open function

<script>
 var1 = "http://ofuran.com";
 var2 = "?ref=Df34hfgT"; var newlink = var1.concat(var2);
</script>

How I use this newlink variable in the following line? please help me by doing.

<?php echo '<script>window.open("http://www.ofuran.com", "_blank"); </script>'; ?>

Upvotes: 1

Views: 185

Answers (2)

Matiur Rahman Mozumdar
Matiur Rahman Mozumdar

Reputation: 451

use the code:

<script>
    var1 = "http://ofuran.com";
    var2 = "?ref=Df34hfgT";
    var newlink = var1.concat(var2);

</script>


<?php echo '<script>window.open(newlink, "_blank"); </script>'; ?>

Upvotes: 1

A l w a y s S u n n y
A l w a y s S u n n y

Reputation: 38502

You can try like this way,

var var1 = "http://ofuran.com";
var var2 = "?ref=Df34hfgT";
var newlink = var1.concat(var2);
window.open(newlink, "_blank");

Upvotes: 1

Related Questions