Opening new window with URL

Hi, I would like to pass a URL from controller to ‘out_view’ where it has to open that URL in new window and open that website url.

Looking forward to hear from you guys soon.

Khan

It’s look like boarded on wrong ship, as nobody reply :)

I think this has to do more of the use of a javascript function than with Yii. Have a look into window.open javascript function at google, plenty of info.

Anyway I really appreciate your feedback Antonio Ramirez, bytheway, I found the way to handle it like this…


<?php echo "<META http-equiv='refresh' content='1;URL= $model->weburl'>"; ?>

or




<?php 

echo '<script type="text/javascript" language="javascript"> 

window.open("'.$model->weburl.'"); 

</script>'; 

?>



edit: Is it what you meant? otherwise, why dont you just use




<?php


header('Location: '.$model->weburl);

?>



but for the above you better do not use a view… just call it from the controller’s action

Thanks for those tips as well and I did update my codes with your second option like this


header('Location: '.$model->weburl);

I really appreciated your more interest and feedback in it. Chao :)

and don’t forget you can close it from the parent opener too:




var childWindow = window.open("'.$model->weburl.'"); 

childWindow.close();



the child window can even access the parent window via:




window.opener.alert('Hey I'm the child window talking to the parent window');



One thing to bear in mind with window.open, is that many browsers will prevent the popup from appearing if it has no user interaction.