Nightasy Posted October 14, 2013 Share Posted October 14, 2013 (edited) Greetings all, I have a bit of challenge that I don't know exactly how to solve. What I am trying to do is open a popup window using javascript and also redirect the page that has the original link on it to a new page. Basically what I want to happen is, user clicks on link, page redirects and a popup window opens at the same time. Sort of like having two links in one. Here's what I tried. It didn't work. echo ' <a href="sectvideo.php?sect=' . $row[0] . '"> ' . "<a href=\"javascript:create_window('".$row[1]."',640,360)\">" . ' <div id="historyUniqueWrap"> <div id="historyUniqueImage"> <img src="'. $row[2] .'"/> </div> <div id="historyUniqueTitleMessageWrap"> <div id="historyUniqueTitle"> <h4>Section: ' . $row[0] . " >>" . '</h4> <p>' . stripslashes($post1). "..." . '</p> </div> </div></a></a> Any ideas? Best Regards, Nightasy Edit: I just had an idea, I could set a condition to be met in the page that is being linked to using a GET. That would solve this issue. I'll try that and report back if it works or not. Edited October 14, 2013 by Nightasy Quote Link to comment https://forums.phpfreaks.com/topic/282964-redirect-current-page-and-open-popup-window/ Share on other sites More sharing options...
Nightasy Posted October 14, 2013 Author Share Posted October 14, 2013 Alright, so I tried to set up the other page to create the popup when it loads if the GET variable is set. Unfortunately this did not work. Here is what I placed on the other page. if(isset($_GET['vidhist'])){ ?> <script type="text/javascript"> create_window(<?php echo $_GET['vidhist']; ?>,640,360); </script> <?php } ?> The javascript is not working when the page loads. It should create a pop up window. Quote Link to comment https://forums.phpfreaks.com/topic/282964-redirect-current-page-and-open-popup-window/#findComment-1453896 Share on other sites More sharing options...
Solution Nightasy Posted October 14, 2013 Author Solution Share Posted October 14, 2013 (edited) I got it working. I had to add the javascript to an onload function. Turned out like this. <?php if(isset($_GET['vidhist'])){ ?> <script type="text/javascript"> onload = function() { create_window(<?php echo '"' . $_GET['vidhist'] . '"'; ?>,640,360); }; </script> <?php } ?> Edited October 14, 2013 by Nightasy Quote Link to comment https://forums.phpfreaks.com/topic/282964-redirect-current-page-and-open-popup-window/#findComment-1453905 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.