javascript

If condition for redirection in jquery?

Edit... Someone suggested I do it differently... If I were to use .htaccess, would this work? Options +FollowSymlinks RewriteEngine on RewriteRule ^chapter http://mysite.com/chapter/1 I'm just using basic javascript here, but I wanted to find out if there's a way to add it to my jquery file so that the redirection will happen if th...

How can I use getElementById for a control created in code behind?

I am trying to use the onmouseover and onmouseout event on a table td created on the client side, so that when the a user mouses over the table cell, a panel becomes visible, and when they mouse out, the panel becomes invisible. <table> <tr> <td onmouseover="ToggleVisibility('FileHeader', true);" onmouseout="ToggleVisibilit...

How to regulate height of LIs?

I have a UL where the LIs are boxes. I want the boxes to all be the same size, but sometimes the boxes are one line, and other times they're two. how do i add an extra empty line in the LI if the content is only one line? I'm assuming this will be some sort of javascript? ...

How to make a javascript redirect within a php if statement

I am developing a personality test, and php result script now just echoes a personality description based on an if statement: if ($i = 5 AND $alpha[$i] >= 9 ) { echo " Description "; } However, instead of this description, I would want to make a redirect to another url. Can't seem to figure this one out. Cheers, Jelmar ...

Get key char (value) from keycode with shift modifier

I have been lucky to find String.fromCharCode(). It has helped me significantly. However, I noticed it doesn't take into account the shift modifier. I know the event.shiftKey property and use it, but right now I need to get the key value (eg: "A" or "a") which takes into account the shift key modifier. At first I used String.toLowerC...

what does this script do? - hacked site

I just came accross a site that has been hacked and I'm wondering what this javascript does. so far as I can tell it attempts to redirect the page somewhere but fails. It looks like it made its way into every last file on the server. <script> function sF() { }; var sMN = new Array(); sF.prototype = { b: function () { ...

Printing iFrame's content in IE8 not working.

Hi guys. I am trying to print the contents in the iframe in ie8 but it's not working. with ff however it does. :c Here is the JS code: $("#print_multi").click(function(){ printpdf(); }); function isIE(){ if(navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER'){return true;} else{return false;} } function printp...

Checking length of dictionary object

I'm trying to check the length here. Tried count. Is there something I'm missing? var dNames = {}; dNames = GetAllNames(); for (var i = 0, l = dName.length; i < l; i++) { alert("Name: " + dName[i].name); } dNames holds name/value pairs. I know that dNames has values in that object but it's still completely skipping over ...

Using AJAX for page items while still allowing them to be opened in a new tab/window

I'm looking at using AJAX to allow some content within part of a page to be reloaded without reloading the entire web page (eg things like overview, reviews, specifications, etc pages about a single item). The problem is however I still want to allow users to open these items in a new tab or window (using the normal systems for their we...

Iterating over json object without using eval?

Sorry, this is probably a duplicate question, but how can I iterate over a list in Javascript inside another object without using eval()? See pseudocode in CAPITALS below: polygon = polygon['coordinates']; //list object var polygon = new CM.Polygon([ FOR POLY IN POLYGON { new CM.LatLng(poly[1], poly[0]), } ]); Obviously, I ...

Problems loading JSON code in Python

I've been tyring to figure out how to load JSON objects in Python. I'm able to send a JSON string to the server, but there it fails. This is what I'm sending through a websocket with JavaScript: ws.send('{"test":"test"}'); The server receives it without a problem, but can't validate it: {"test":"test"} This is not a JSON object! ...

Wrapping an Element using Pure JavaScript !!

Hello, I have a series of div tags on my page & I want to wrap them all into a container. <div class = "c" >blah blah </div> <div class = "c" >blah blah </div> <div class = "c" >blah blah </div> I want to wrap all the above tags into a container as follows <div class="container" > <div class = "c" >blah blah </div> <div cl...

How to embed HTML via JS embed code.

I need to give the user a snippet of js code that will insert some HTML code into the page. I'm wondering what the best method to do so is. Should I use document.write, should I just create all the HTML elements via DOM programmatically? Is it possible to use a js library? I can see conflicts occurring if the webpage the code is embed...

Windows User Agent

Here is my code: <script type="text/javascript"> if (navigator.userAgent.indexOf('BlackBerry')!= -1){ document.write('<link rel="stylesheet" href="/m/css/mobile.css" type="text/css" />'); } else if (navigator.userAgent.indexOf('iPhone')!= -1) { document.write('<link rel="stylesheet" href="/m/css/smartmobile.css" type="text/css"...

Why does this code alert three undefined values?

Why does this code alert three undefined values? <html> <head> <script type="text/javascript" language="javascript"> function doIt(form){ alert(form.elements.length) for (var i in form.elements){ alert(form.elements[i].value); } ...

Radio button group - change events for buttons become deselected?

Let's say I have a group of two radio buttons: <input type="radio" name="radioButtonGroup" value="button1" checked="true"/> <input type="radio" name="radioButtonGroup" value="button2"/> It seems that clicking the second button triggers an event handler on that button only. However, the first button does become deselected, and visually...

toFixed vs toPrecision?

Hello I'm new to javascript. just discovered toFixed & toPrecision to round numbers but i can't figure what is the diff between both? thanks ...

Does nesting affect efficiency?

Consider languages like Python or JavaScript that allow functions to be nested like this: print(vector(a * b),(a * c),(b * c))) or flat like this: i = (a * b) j = (a * c) k = (b * c) V = vector(i,j,k) print(V) How much does the different format affect performance? Can valid generalizations be made, or does it vary a lot by language...

How to set a Javascript-HTML variable from a Android code.

Hi, I am trying to set the value of a global variable from Android code. mWebView.loadUrl("javascript:(function() { " + "loginID = '"+nicu_app.urlSelected+"'; " + "})()"); but when I load the webpage in a webview and check to see if this variable has been set by the A...

Can I Include different javascript/css files per Content Page using ASP.NET WebForms Master Pages?

I have several Content Pages using the same Master Page, that don't all need the same javascript and css files included in the <head> tag. Is it possible to change the contents of the <head> tag from the Content Pages? ...