Via jquery / Javascript
Given a number 1234567891234
How can I concat, or truncast By removing the 2 from the left to make that number a valid integer I can insert into MySQL:'
4567891234
Thanks
I was wondering - can a crawler be written entirely in javascript? That way, the crawler is only called when a user needs the information and everything is run from the individual user's computer
I'm using this simple code: http://ejohn.org/blog/simple-javascript-inheritance/
Using this "library", I made this simple class:
var Person = Class.extend({
init: function(openningSentence) {
this.say(openningSentence);
},
say: function(words) {
alert(words);
}
});
The problem with this class, is that I can't call a function using the variable "this" (line 3 in the code gives an error: unknown method "say").
Does anybody knoes if there's a solution for this problem?
Btw - I'm using jquery, so if there's a jquery-based solution It'll be great :)
I originally had the following callback passed as a parameter to the javascript array sort() function:
function sortNumber(a,b) {
return a-b;
}
However this doesn't work when my array contains positive and negative decimal numbers (i.e. -107.578, 97.453 etc.) How would I modify this to sort properly?
Hi,
I need to open a javascript dialog (either window.open or window.showModalDialog will do), from an opensocial gadget.
It's just to make the OAuth flow. The problem is that the window gets blocked by the popup blockers.
I know this is possible because facebook gadget does that.
Any ideas please?
What's the best way to validate an email address in Javascript?
Though this solution may be simple, I'm sure this is one of those useful things that people will be Googling for and deserves its own entry on the site
I want to do this but dont know how to do it in JavaScript.
if (Email == "*aol.com" || Email == "*hotmail*" || Email == "*gmail*" || Email == "*yahoo*")
{
alert("No Hotmail, Gmail, Yahoo or AOL emails are allowed!");
return false;
}
Any way around this?
I'm using Django on Appengine. I'm using the django reverse() function everywhere, keeping everything as DRY as possible.
However, I'm having trouble applying this to my client-side javascript. There is a JS class that loads some data depending on a passed-in ID. Is there a standard way to not-hardcode the URL that this data should come from?
var rq = new Request.HTML({
'update':this.element,
}).get('/template/'+template_id+'/preview'); //The part that bothers me.
Hallo all.
I got a javascript object with some propeties let's say
function Animal() {
this.id;
this.name;
I need to call id function in a dynamic way to get and set its value: something like this
Animal animal = new Animal();
var propertyName = "id";
animal.+propertyName = "name";
Is there an elegant way to do it? With jQuery?
Kind regards
Massimo
I am looking for a way to insert javascript code block to end of ASP.NET page.
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "showVideo", sScript, true);
is appending to body but js codes are always requesting some js files didn't load or some functions are below of the script.
How can i append scripts that i generated dynamically to the bottom of body?
Thanks for your help.
In normal javascript, I can check either
if (i == undefined)
or
if (i === undefined)
or the "typeof"
however, within facebook, it will have the api_key append as the prefix in undefined.
i.e. it will become
if (a12345_i == a12345_undefined)
which is NOT undefined
so, what can I do to find out the variable is undefined or not?
Hi,
I am creating Hang a Man using PHP, MySQL & Javascript. Every thing is going perfect, I get a word randomly from DB show it as a label apply it a class where display = none. Now when I click on a Character that character become disable fine which i actually want but the label-character does not show.
My code is:
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<?php
include( 'config.php' );
$question = questions(); // Get question.
$alpha = alphabats(); // Get alphabets.
?>
<script language="javascript">
function clickMe( name ){
var question = '<?php echo $question; ?>';
var questionLen = <?php echo strlen($question); ?>;
for ( var i = 0; i < questionLen; i++ ){
if ( question[i] == name ){
var link = document.getElementById( name );
link.style.display = 'none';
var label = document.getElementById( 'questionLabel' + i );
label.style.display = 'block';
}
}
}
</script>
<div>
<table align="center" style="border:solid 1px">
<tr>
<?php
for ( $i = 0; $i < 26; $i++ ) {
echo "<td><a href='#' id=$alpha[$i] name=$alpha[$i] onclick=clickMe('$alpha[$i]');>". $alpha[$i] ."</a> </td>";
}
?>
</tr>
</table>
<br/>
<table align="center" style="border:solid 1px">
<tr>
<?php
for ( $i = 0; $i < strlen($question); $i++ ) {
echo "<td class='question'><label id=questionLabel$i >". $question[$i] ."</label></td>";
}
?>
</tr>
</table>
</div>
Anyone know a way to obfuscate javascript before it's outputted to the browser? I was using
http://www.javascriptobfuscator.com/
But I'm hoping there is a library that can do this on the fly.
Help appreciated.
Is there any way with jQuery or javascript to trigger a function when the user ends to resize the browser window ?
In other terms:
1) Can I detect mouse up event when user is resizing the browser window ?
otherwise
2) Can I detect when a window resize operation is finished ?
I'm currently only able to trigger an event when the user start to resize the window with jquery
thanks
In javascript, If i have a text block like so
Line 1
Line 2
Line 3
What would i need to do to lets say delete the first line and turn it into:
Line 2
Line 3
I would like to implement a Python script which has the same functionality as http://www.greymagic.com/security/tools/decoder/
Is the encoding rule open for this type of javascript code encoding?
Thanks.
I have JSF code like:
<h:inputText id="from" value="#{fromToMBean.fromName}"/>
I would like to get this element from JavaScript by ID (from), but I can't, because in generated HTML it is j_idt8:from
How can I get this element in e.g. jQuery? Is there any way to force JSF2 not to change ids?
Dear friends,
I tried to
1) load an xml file using javascript as an object, say "note.xml"
2) then save the object to a new xml file, say "note_new.xml"
I did 1) but failed 2)
I tried to use method save() to do 2). After my failure, I checked ms site and they said save() is not supported....
could some one enlighten me how to do the save?
thank you!
here is the code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<h1>W3Schools Internal Note</h1>
<p><b>To:</b> <span id="to"></span><br />
<b>From:</b> <span id="from"></span><br />
<b>Message:</b> <span id="message"></span>
<script type="text/javascript">
if (window.ActiveXObject){
alert("there is ActiveXObject");
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("note.xml");
}else{
alert("i am not withActiveXObject!");
xhttp=new XMLHttpRequest();
xhttp.open("GET","note.xml",false);
xhttp.send("");
xmlDoc=xhttp.responseXML;
}
xmlDoc.save("note_new.xml");
</script>
</body>
</html>
update:
seems this is related to security issue. I appologize to those experienced programmers for my putting this question in a rush because it seems a newbie question.
I'm currently using Visual Studio 2008 to edit .js files with, and it has decent support but I want more...
I like the VS syntax highlighting and auto-indentation features but additionally would like advanced features like: contextual info and help, collapsible JavaScript blocks, implicit symbol understanding for searching, refactoring and that kind of thing; also warnings and errors for the js code.
Suggestions?
Hello All
I am using javascript associative array like:
var testarray = [];
testarray['one'] = '1';
testarray['two'] = '2';
testarray['three'] = '3';
I am also using jquery alongside. How can I check length of this associative array using jquery or any other method? Basically i want to check whether this array is empty or not.
Thank you.
Hello!
How do I load photoshop's action using its javascript scripting language?
Mostly curious in this action steps:
Add Noise
Distribution: gaussian
Percent: 2%
With Monochromatic
Texturizer
Texture Type: Canvas
Scaling: 100
Relief: 3
Without Invert Texture
Light Direction: Top Left
I use the below code to write code to query a web method in a specified interval.
now in the this.Poll function I have to do
this.tmo = setTimeout(this.strInstanceName + ".Poll()", this.iInterval);
instead of
this.tmo = setTimeout(this.Poll(), this.iInterval);
because IE looses the this object after setTimeout
So I have to pass the class it's instance name:
var objPoll = new cPoll("objPoll");
How can I get the instance name without passing it as parameter ?
I want to have it outta there !
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Intervall-Test</title>
<script type="text/javascript" language="javascript">
function test()
{
alert("Test");
test.tmo = setTimeout(test, 2000);
test.Clear = function()
{
clearTimeout(test.tmo);
}
}
function cPoll(strInstanceName)
{
this.strInstanceName = strInstanceName ;
this.iInterval = 2000;
this.tmo=null;
this.cbFunction=null;
alert(this.Name );
this.Poll = function()
{
this.cbFunction();
this.tmo = setTimeout(this.strInstanceName + ".Poll()", this.iInterval);
}
this.Start = function(pCallBackFunction, iIntervalParameter)
{
if(this.tmo != null)
this.Stop();
if(iIntervalParameter && iIntervalParameter > 0)
this.iInterval=iIntervalParameter;
this.cbFunction=pCallBackFunction;
if(this.cbFunction!=null)
this.Poll();
else
alert("Invalid or no callback function specified");
}
this.Stop = function()
{
if(this.tmo != null)
{
clearTimeout(this.tmo);
this.tmo=null;
}
}
}
function CallBackFunction()
{
alert("PollCallBack");
}
// test();
// test.Clear();
var objPoll = new cPoll("objPoll");
</script>
</head>
<body>
<h1>Test</h1>
<input type="Button" value="Start polling" onclick="objPoll.Start(CallBackFunction,3000);" />
<input type="Button" value="Stop polling" onclick="objPoll.Stop();" />
</body>
</html>
Hi All,
I want to disable browser refresh using javascript.
Actually i am using window.onbeforeonload abd i don't want it will be called when user refresh the browser.
what is the best way to do it?
Regards,
Salil Gaikwad
I need parse a string inside a parenthesis, which looks like (A, B, C), where A, B, and C are string that can contain any legal JavaScript code. For example, B might be a very long string with nested structures similar to (A, B, C). What would be the best way to parse such a string?