how to assaign string to variable in javascript?

Posted by Hariinakoti under JavaScript on 9/21/2012 | Points: 10 | Views : 1947 | Status : [Member] | Replies : 10
Hi Friends,
how to assign string to variable in javascript? is it possible?

Thanks & Regards
Hari



Responses

Posted by: Vikash on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
Use the following simply..

var str="Hariinakoti";


Regards,
Vikash Pathak

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
Hi vikash,
var xWin=null;
function StartPopup(){
xWin=window.open("popuptest.htm","","");
alert('xWin ' +xWin);
setTimeout("test_xWin()",700);
}
here variable return object.but i want string.is it possible?

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vikash on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Cast your object with String like following

var objct = obj;

var str=String(objct);

else provide complete code ..

Regards,
Vikash Pathak

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
can i provide full code?

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vikash on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
yes..

Regards,
Vikash Pathak

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
See my code plz.
<script language="javascript" type="text/javascript">
ns4=document.layers
ie8=document.all
ns6=document.getElementById&&!document.all
var xWin=null; var ticks=6;
function ChangeLabel0(txt){
if(ns4){document.layers.label0.innerHTML=txt}
if(ie8){document.all.label0.innerHTML=txt}
if(ns6){document.getElementById("label0").innerHTML=txt}
}

function StartT(){
StartPopup();
window.focus();
ChangeLabel0("<b>Popup window appears in "+ticks+" sec. Wait please...</b>");
}
function StartPopup(){
xWin=window.open("popuptest.htm","","");
alert('xWin ' +xWin);
setTimeout("test_xWin()",700);
}
function test_xWin(){
// alert("typeof(xWin)="+typeof(xWin));
// alert("typeof(xWin.location.href)="+typeof(xWin.location.href));
// alert("xWin="+xWin);
// alert("xWin.location.hash="+xWin.location.hash);
if ( (xWin==null)||(typeof(xWin)=="undefined") ||(typeof(xWin.location.hash)!="string")
// ||(xWin.location.hash!="#abc")
){sMsg="<font color=#FF0000><b>A popup killer is detected</b></font>";}
else{sMsg="<font color=#008000><b>There is NO popup killer detected</b></font>";};
//alert("xWin="+xWin+" type="+typeof(xWin)+" typeloc="+typeof(xWin.location.hash)+" hash="+xWin.location.hash);
window.focus();
ChangeLabel0(sMsg);
}
function hi()
{
alert('hi');
StartT();
return false;
}
</script>
</head>
<body onload="return hi();" >
<form id="form1" runat="server">
<div id="label0"></div>
</form>
</body>
</html>

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 9/22/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
noramlly javscript assign string varibale what u need this code? can u explain.

Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/22/2012 [Member] Starter | Points: 25

Up
0
Down
i want to check popup blocker in internet explorer in all versons using Javascript? that is the code only i posted above.
it is working in another browsers except ie.i want to check it is in IE plz check that once.

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vikash on: 9/22/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Hariinakoti
i ve checked it ..
it's working fine in IE9, but i don't know about other lower version......

Regards,
Vikash Pathak

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/22/2012 [Member] Starter | Points: 25

Up
0
Down
it is working in ie9 but i want in lower versions also.In my company using ie7&8

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response