Opening new window with Given URL | window.open()

Hi Yii members,

i have encountered a problem on loading a new url in window.open() method.

what i wanted is, when i give something like below.

window.open(‘www.facebook.com’, ‘window name’, ‘window settings’);

i wanted the www.facebook.com to be loaded on a new tab. but sadly what happens is its loading the facebook url wrongly. this way… http://localhost/mysite/index.php/admin/coupon/[color="#FF0000"]www.facebook.com[/color]

i tried all ways but unfortunately still i am getting the same page which is a wrong url. when i do the same in a new php page it is loading and working well. but inside yii when i call window.open() method its appending to the current url like i said before.

can anyone please explain me why this happens in yii ?

any help would be highly appreciated.

tnx

mazraara

what are you use for operation? ( simple core html or Yii CHtml format ?)

can you post your code?

use this,


<?php echo CHtml::link('Link Text','http://facebook.com', array('target'=>'_blank')); ?>

its a simple javascript.

the code is as follows.

//test fb url

  &#036;('a#fbtesturl').click(function(){


      var fburl = &#036;('#fb_url').val();


	  window.open(fburl, 'window name', 'window settings');


	  return false;


	});

when the user clicks the link which has the id #fbtesturl it will take the given url from text box and open it on a new tab.

i want to load the relative url. but i dont understand why its taking the absolute url. which is something like this… http://localhost/mys...p/admin/coupon/[color="#FF0000"]www.facebook.com[/color]

where it must be just… http:www.facebook.com :(

thanks for you comments. pls let me know weather you know a way to fix this. tnx

uppp

here i had created simple demo with yii CHtml elements and simple javascript;

javascript open new window with url specified in textbox.


<script>

function test(){

	var url = document.getElementById('test').value;

	window.open(url);

}

</script>

Below is link and textbox, clicking on link it will open the url in new window which is specified in textbox : use url with http ( i.e: http://facebook.com )

Link code below


<?php 

echo CHtml::link("test", '#', array ('onClick'=>'test();' ))

?>

Textbox code below


<?php echo CHtml::textField('Text', '',

 array('id'=>'test', 

 		'name'=>'test',

   	'width'=>100, 

   	'maxlength'=>100)); ?>

above is flow and idea, you can modify in way as you want.

[size="3"]Hey Kiran really appreciate you help. i found the bug and it was my mistake.

i have forgotten to include the http:// along with the url.

when i give so, it worked like a princess.

many thanks[/size]

:rolleyes: