开发者

Open a new window for each url created

开发者 https://www.devze.com 2023-02-26 06:52 出处:网络
I want to open a new window for each $url created how could I do that? <?php require_once(\'sql.php\');

I want to open a new window for each $url created how could I do that?

<?php
require_once('sql.php');

$result = mysql_query("SELECT * FROM gamertags ORDER BY id DESC LIMIT 10");

while($row = mysql_fetch_array($result)){
    // Prepare gamertag for url
    $g开发者_运维问答amertag = strtolower($row['gamertag']);
    $url = "http://halogamertags.com/tags/index.php?player_name=".urlencode($gamertag);
}
?>


you can do it with a combo of javascript and ur current script:

<?php
require_once('sql.php');

$result = mysql_query("SELECT * FROM gamertags ORDER BY id DESC LIMIT 10");
echo "<script>";
while($row = mysql_fetch_array($result)){
    // Prepare gamertag for url
    $gamertag = strtolower($row['gamertag']);
    $url = "http://halogamertags.com/tags/index.php?player_name=".urlencode($gamertag);
    echo "window.open('$url');".PHP_EOL;
}
echo "</script>";
?>


Warning ~ Will attempt to open 10 windows on load:

Live Demo

$("#gamertags a").each(function() {
    window.open($(this).attr('href'), 'Player Details', 'width=500,height=500');
});


In your generated HTML, use target="_blank" to cause a new new window to be launched when the link is clicked.

<a href="url" target="_blank">Link</a>

You can't do it in PHP since it's a server since it's server side. You might also do it from JavaScript but more information would be useful.

In JavaScript, you can use the window.open() method

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号