|
IE String Object (literal) (JScript)
Allows manipulation and formatting of text strings and determination and location of substrings within strings.
String is not a collection and not array. Use operator + or method concat.
To convert a JScript-string into array use method split.
To convert a numeric value into String use method parseInt.
Syntax
newString = new String(["stringLiteral"])
Arguments
newString
Required. The variable name to which the String object is assigned.
stringLiteral
Optional. Any group of Unicode characters.
Remarks
String objects can be created implicitly using string literals. String objects created in this fashion
(referred to as standard strings) are treated differently than String objects created using the new operator.
All string literals share a common, global string object. If a property is added to a string literal, it
is available to all standard string objects:
var alpha, beta;
alpha = "This is a string";
beta = "This is also a string";
alpha.test = 10;
In the previous example, test is now defined for beta and all future string literals. In the following example,
however, added properties are treated differently:
var gamma, delta;
gamma = new String("This is a string");
delta = new String("This is also a string");
gamma.test = 10;
In this case, test is not defined for delta. Each String object declared as a new String object has its own set of members.
This is the only case where String objects and string literals are handled differently.
Properties
constructor
length
prototype
Methods
anchor
big
blink
bold
charAt
charCodeAt
concat
fixed
fontcolor
fontsize
fromCharCode
indexOf
italics
lastIndexOf
link
match
replace
search
slice
small
split
strike
sub
substr
substring
sup
toLowerCase
toUpperCase
toString
valueOf
Examples
// A primitive string.
var string1 = "Hello";
// Two distinct String objects with the same value.
var StringObject1 = new String(string1);
var StringObject2 = new String(string1);
// An object converts to a primitive when
// comparing an object and a primitive.
print(string1 == StringObject1); // Prints true.
// Two distinct objects compare as different.
print(StringObject1 == StringObject2); // Prints false.
// Use the toString() or valueOf() methods to compare object values.
print(StringObject1.valueOf() == StringObject2); // Prints true.
length Property (String)
Returns the length of a String object.
strVariable.length
"String Literal".length
The length property contains an integer that indicates the number of characters in the String object.
The last character in the String object has an index of length - 1.
|
|
|
|
|
I am working with Google Maps embedded on my webpage. What I want is to create a button click event, so that after a user has entered an address into a textbox (called txtBoxMaps), they can click a button which will display the new location on the same webpage. I tried using: google.maps.event.addListener(map, 'click', function(event) but when I click the button (btnDisplay) nothing happens. I can see the google map but it doesnt change after the "Display" button is clicked.
Here is my code below:
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<style type="text/css">
.style1
{
width: 104px;
}
.style2
{
width: 144px;
}
#GO
{
width: 92px;
}
#Display
{
width: 113px;
}
</style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script type="text/javascript">
function Initialize() {
var mapOptions = {
center: new google.maps.LatLng(-33.01, 27.9),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('GMap1'), mapOptions);
google.maps.event.addListener(map, 'click', function(event) {
mapZoom = map.getZoom();
startLocation = event.latLng;
var input = document.getElementById('TextBox1');
});
}
google.maps.event.addDomListener(window, 'load', Initialize);
</script>
<input type="text" id="TextBox1"/>
<input type = "button" id="btnDisplay" value = "Display"/>
<div id="GMap1" style="height: 240px; width:570px" ></div>
|
|
|
|
|
You have to divide the functions in 2 or 3 parts
Initilize, drawMap
And then call drawMap on the button click
function intialize() {
drawMap();
}
function drawMap() {
var mapOptions = {
center: new google.maps.LatLng(-33.01, 27.9),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('GMap1'), mapOptions);
google.maps.event.addListener(map, 'click', function(event) {
mapZoom = map.getZoom();
startLocation = event.latLng;
var input = document.getElementById('TextBox1');
});
}
|
|
|
|
|
hi, i am trying to build dynamic list for my jquery mobile app. but i get an syntax error... can any one check this code out pls. ty
function appointmentList(url, title, row1, row2, row3, tlf, task, done, datetime, endDate) {
/*var error_str = "Undefined";
if (title == undefined || title == "") { title = error_str; }
if (row1 == undefined || row1 == "") { row1 = error_str; }
if (row2 == undefined || row2 == "") { row2 = error_str; }
if (row3 == undefined || row3 == "") { row3 = error_str; }
if (datetime == undefined || datetime == "") { datetime = error_str; }
if (tlf == undefined || tlf == "") { tlf = error_str; } */
String statusStr = "";
if(done == "3") {
statusStr = "<b style='color:#009933;'>Utført</b></span></li>";
}
else if(done == "2"){
statusStr = "<b style='color:#FFCC00;'>Pågår</b></span></li>";
}
else if(done == "1") {
statusStr = "<b style='color:#FF0000;'>Ikke utført</b></span></li>";
}
else {
statusStr = "</span></li>";
}
var buildList += "<li data-role='list-divider'>" + title + "<span class='ui-li-count'>" + formatDateTime(datetime) + plainToHtml(' - ') +formatDateTime(endDate) + plainToHtml(statusStr);
buildList += "<li>";
buildList += "<div class='ui-grid-a'>";
buildList += "<div class='ui-block-a'>";
buildList += "<h4>" + plainToHtml(row1) + "</h4>";
buildList += "<h4>" + plainToHtml(row2) + "</h4>";
buildList += "<h4>" + plainToHtml(row3) + "</h4>";
buildList += "<b>Tele:" + "<a href='tel:" + tlf + "'>"+ String(tlf) + "</a></b>";
buildlist += "</div>";
buildlist += "<div class='ui-block-b'>";
buildlist += "<div class='appIcons' style='float:left;'>";
buildlist += "<a href='#nysak' data-transition='slide'><img src='icons/add-icon.png' style='margin-left:1em;'></a>";
buildlist += "<a href='#siste' data-transition='slide'><img src='icons/saker.png' style='margin-left:1em;'></a>";
buildlist += "<a href='#mote' data-transition='slide'><img src='icons/task.png' style='margin-left:1em;'></a>";
buildlist += "</div>";
buildlist += "</div>";
buildlist += "</div>";
buildlist += "</li>";
return buildList;
}
|
|
|
|
|
Member 10220480 wrote: but i get an syntax error It would help if you explained where.
Use the best guess
|
|
|
|
|
Member 10220480 wrote: }
Check your brackets. Some of them are backwards.
|
|
|
|
|
mmm... to many days coding, cant find it m8. can you pls tell me whare?
|
|
|
|
|
oo found it
ty
|
|
|
|
|
need to show which line it is missing.
|
|
|
|
|
where you are getting error ?
|
|
|
|
|
String statusStr = ""; --> var statusStr = "";
var buildList += " var buildList = "
|
|
|
|
|
String statusStr = "";
use var statusStr = "";
i hope this will get solution to u
|
|
|
|
|
ty for the help guys
|
|
|
|
|
can you please provide error line where you exactly getting
|
|
|
|
|
This is my java script.its lace on a image and when i click the circle it enlarges. But when i click it again it should be the normal size again. See the image below.. http://i.imgbox.com/adbuiwsa.png[^]
This is the code for the javascript circle.What i need is when i click the blue circle again it should be the normal size again... How do i code it?? I preffer is it is done using a variable...Pls help me guys.
$('#c1').click(function () {
clearCircle()
ResetCircle()
$(this).removeClass("blink1");
$(this).css('width', '190px');
$(this).css('height', '190px');
$(this).css('top', 243 - ((190 - 125) / 2));
$(this).css('left', 335 - ((190 - 125) / 2));
$(this).css('background-image', 'URL(assets/images/blue_back.png)');
});
|
|
|
|
|
Hey
What you can do is, you can move the following styles to a class:
$(this).css('width', '190px');
$(this).css('height', '190px');
$(this).css('top', 243 - ((190 - 125) / 2));
$(this).css('left', 335 - ((190 - 125) / 2));
$(this).css('background-image', 'URL(assets/images/blue_back.png)');
and you javascript will look as follows:
$('#c1').click(function () {
clearCircle()
ResetCircle()
$(this).removeClass("blink1");
if ($(this).hasClass("YourClass")) {
$(this).removeClass("YourClass");
} else {
$(this).addClass("YourClass")
}
});
|
|
|
|
|
Thanks! Appreciate it!
|
|
|
|
|
you have to call the .css all in one line, or else each one will overwrite the previous.
or use
$(this).style.width = "100px";
$(this).style.height = "32px";
or use
$(this).style.cssText = "width: 100px; height: 32px;";
|
|
|
|
|
iam new for javascript. how to kill or terminate the specific process from taskmanager.
please let me know if anybody have an idea about this.
<html>
<body>
<script>
w = new ActiveXObject("WScript.Shell");
w.run("taskkill.exe /im notepad.exe");
</script>
</body>
</html>
Regards,
Srinivas
|
|
|
|
|
You can't. Giving a website access to terminate processes on the user's computer would be a massive security risk. If there was any way to do it, it would have been found, exploited, and patched many years ago.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
w = new ActiveXObject("WScript.Shell");
that ist Windows Host Script (WHS) and NOT Javascript.
ActiveX only useable with windows.
Javascript is a languange not only for browsers run unter windows.
w.run("taskkill.exe /im notepad.exe");
Use WHS inside browser: Only Internet Explorer.
|
|
|
|
|
JavaScript is the client side scripting language and you can not access Task Manager using JavaScript. So, you can not kill any process using JavaScript. Also, a website have access to only some specific folders of the drive and that access is very limited. You can not access anything outside those specific folders.
|
|
|
|
|
DropDown onchange event table row will be visible/invisible is not working in IE8 but in chrome its working fine.the code in given below. plz help me...is there any wrong in this code?....Thanks in advance.......
var $ = Object.prototype.$ = function(id){ return document.getElementById ? document.getElementById(id) : document.all ? document.all[id] : null };
function showHideTableRow(tr, show){
if(!tr){ return false; }
try{
tr.style.display = (show) ? '' : 'none';
return true;
}
catch(e){
tr.style.display = (show) ? '' : 'none';
return true;
}
}
function selAction(sel){
for(var i=0; i<sel.options.length; i++){
var trID = sel.options[i].getAttribute('bindTo');
if(trID !== ''){
var tr = $(sel.options[i].getAttribute('bindTo'));
var rtnVal = showHideTableRow(tr, i == sel.selectedIndex);
}
}
}
|
|
|
|
|
styles of object table only IE
are e.g.
style.display display Sets or retrieves whether the object is rendered.
style.visibility visibility Sets or retrieves whether the content of the object is displayed.
visibility only IE
visibility Attribute | visibility
Syntax
HTML { visibility : sVisibility }
Scripting object.style.visibility [ = sVisibility ]
sVisibility String "inherit" Default
"visible"
"hidden"
Example 1
<STYLE>
.vis1 { visibility:visible }
.vis2 { visibility:hidden }
</STYLE>
</HEAD>
<BODY>
<IMG ID="oSphere" SRC="sphere.jpg">
<P onmouseover="oSphere.className='vis2'"
onmouseout="oSphere.className='vis1'">
Move the mouse over this text to make the sphere
disappear.</P>
Example 2
<SCRIPT>
function disappear()
{
oSphere.style.visibility="hidden";
}
function reappear()
{
oSphere.style.visibility="visible";
}
</SCRIPT>
</HEAD>
<BODY>
<IMG SRC="sphere.jpeg" ID="oSphere">
Move the mouse over <SPAN ID="oTxt" onmouseover="disappear()"
onmouseout="reappear()"> this text</SPAN>
to see the sphere disappear.
display only IE
display Attribute | display
Syntax
HTML { display : sDisplay }
Scripting object.style.display [ = sDisplay ]
sDisplay String "block" IE 5.x and above
"none"
"inline"
"inline-block"
"list-item"
"table-header-group"
"table-footer-group"
default is "inline"
but default is block for
ADDRESS
BLOCKQUOTE
BODY
CENTER
COL
COLGROUP
DD
DIR
DIV
DL
DT
FIELDSET
FORM
Hn
HR
IFRAME
LEGEND
LI unter IE 6.x
LISTING
MARQUEE
MENU
OL
P
PLAINTEXT
PRE
TABLE
TD
TH
TR
UL
XMP
but default is "none" for
BR
FRAME
nextID
TBODY
TFOOT
THEAD
but default is "list-item" for
LI IE 6.x and above
Example 1
<SPAN ID=oSpan>
This is a SPAN
</SPAN>
in a sentence.
<P>
<INPUT TYPE=button VALUE="Block"
onclick="oSpan.style.display='block'">
:
Example 2
<SCRIPT>
function getPets()
{
oRow1Cell2.style.display="none";
oRow2Cell2.style.display="block";
oRow3Cell2.style.display="none";
}
</SCRIPT>
:
<TABLE>
<TR ID="oRow1"><TD>Horses</TD>
<TD ID="oRow1Cell2">Thoroughbreds</TD>
<TD>Fast</TD></TR>
<TR ID="oRow2"><TD>Dogs</TD>
<TD ID="oRow2Cell2">Greyhounds</TD>
<TD>Fast</TD></TR>
<TR ID="oRow3"><TD>Marsupials</TD>
<TD ID="oRow3Cell2">Opossums</TD>
<TD>Slow</TD></TR>
</TABLE>
:
<INPUT TYPE=button onclick="getPets()"
VALUE="Show household pets">
|
|
|
|
|
please use <pre> tag for code formatting and more redablity
|
|
|
|