javascript

dynamic iframe height depending on...

Is there any javascript algo that i can used to check for a website page height and put it as height of the iframe to render the page step 1 : check what is the height of the website , let say www.cnn.com.my step 2 : get the height , and put in ? step 3: render the page in iframe with height 'pre-set' ...

firefox/safari/ie top margin ,left margin 0

if i use <BODY TOPMARGIN=0 LEFTMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0> tag like this, will this ensure element i put in my html will displayed the same across all browser? the reason i asking this is because, i was told Internet explorer renedering of the page is slightly different .In other words, if i put img tag in a page and rende...

this.type='password' doesn't work in IE, but all other browsers it does

I have an input field that is by default set to type="text" so that the word Password can be displayed in it. I have the following to change it to a password field when the user selects it, which works fine in any browser I have tried except Internet Explorer. onfocus="this.type='password';" How would I go about making this work in I...

How can I separate javascript from PHP when the JS needs a PHP variable?

Below is a small snippet from a code I saw with jquery and PHP. Notice the PHP part on line 5, I generally put my javascript into separate files so how would I be able to keep my JS in separate files but still use PHP when needed like below? //when the DOM is ready $(document).ready(function(){ //settings on top var domai...

How does codeandtheory's live search work?

I've been trying to figure out how the "live search" function at http://www.codeandtheory.com/#/work/ works. I've looked at in firebug, and have looked at a bunch of AJAX search tutorials but codeandtehory's seems to work a lot "smoother". Any ideas? ...

Blind with jQuery

I'm trying to write a blind function that would close a DIV in a display:none mode. The unseen DIV is inside a wider DIV, containing the blind trigger. This: $(document).ready(function(){ $("#toggle_blind").click(function () { $(this).toggle("fast"); }); }); Well, this blinds the button. How can I add a DIV to $this? Som...

Converting a Javascript array to a function arguments list

Is it possible to convert an array into a function argument sequence? Example: run({ "render": [ 10, 20, 200, 200 ] }); function run(calls) { var app = .... // app is retrieved from storage for (func in calls) { // What should happen in the next line? var args = ....(calls[func]); app[func](args); // This is equivalent...

JavaScript form focus, does my code look okay?

This morning I asked a pretty mundane question about my JS syntax, and someone suggested I use their code instead, so I went ahead with it because I know virtually Zero about JS. Using my moderate PHP knowledge, I made a slight modification adding a second ID with an 'else if' statement (see below) and was just wondering if you folks wh...

Alternate way to load javascript counter script

I am trying to load the statcounter script from my custom js file. The original script looks like this: <html> <head>...</head> <body> ... <script type="text/javascript"> var sc_project=11111111; var sc_invisible=1; var sc_partition=11111111; var sc_click_stat=1; var sc_security="11111111"; </script><script type="text/javascript" src="h...

jQuery/jqGrid: populate select boxes with multiple values

Hello! I'm setting up a jqGrid which needs to visualize multiple values in one cell. The input comes from a form where the user can select multiple choices. I am able to display the select box, but not populate it. I have tried to insert an array in the JSON object, but to no success. This is the model: index:'ship', editoptions:{mult...

A simple javascript script gone bad!

Hello All. I'm trying to set up a simple script to toggle a link from a checkbox. The script I have below works, however it only changes the href of the FIRST instance. I'm sure there's probably a much simpler way of doing this too, as I have a lot of redundant code. Can anyone help shed some light on this for me? Thanks! Nick <...

javascript Replace number output from array with an image.

Hello all, I have a code wich I´d like to alter to output a image instead of a number The image should only be displayed for the so called pick output. There is a structure in the images I'd like to use, so if somebody could be so nice to have 1 or 2 explained, I can do the other 43 :) Example, here is an working example of the code t...

Same JS function -- Many times?

I previously got this (useful!) answer about using .next() for same DIV blind effect. However, I can't seem to get this simple function to work for more than one DIV at the same time: $(document).ready(function(){ $("#closeButton").click(function (){ $(this).next().toggle("fast"); }); }); Any ideas? Thanks. ...

How can I insert this block of html into a page from a json response with jquery?

<script type="text/javascript"> var dataString2 = 'run=captchagood&comment=' + comment; $.ajax({ type: "POST", url: "process.php", data: dataString2, dataType: "json", error: 'error', success: function (data) { if (data.response === 'captchasuccess') { $('div#loader').find('img.load-gif').remo...

Best practices of porting C# server logic to client JS?

Sometimes in order to make our application more responsive and fast, we use client JS. Are there any best practices of effective porting C# code to JS? Things that come to my mind are: - parameterizing scripts - generating scripts - dynamic or static script linking - usual workarounds for typical cases as validation. - synchronizin...

Does JSLint improve your Javascript coding?

Douglas Crockford says: JavaScript is a sloppy language, but inside it there is an elegant, better language. JSLint helps you to program in that better language and to avoid most of the slop. Do those programmers who use JSLint on a regular basis have the same opinion? ...

javascript array output in table

Hello all, I have a code wich works very nice and I had great help here. The only thing is dat the array players output are not very nice lined up with eachother in a table. My question is, how can this code (array players output) be modified to have it nicely lined up? <html> <head> <title>Lotto van Terwijn</title> <body> <p><im...

jQuery ajax load() java script not executing?!

Hey guys, I've read several posts about this issue but i can't solve it. I am loading an html file into a div. The file i am loading contains a unordered list. This list should be expanded (a menu with submenu items) and closed. Therefore i need js. But unfortunately this script isn't loaded. Can anyone help me? Would be so great! Th...

javascript function not get called when arguments from php

I am running the < a > tag in php. Whenever I pass an argument in js function it does not get called but if i pass empty arguments, the function gets called. js: function displayBigImage(img){ alert("inside func"); } php: //NOT WORKING: echo "<a href='javascript:displayBigImage('".$row['IMG_ID']."')'>Press</a>"; //WORKING: echo "...

Checking String Content with Javascript

I've got myself a project where I have to determine if a string contains set string. Example: What I'm looking for "website.com" What is might look like "jsngsowebsite.comadfjubj" So far my own endevours have yielded this: titletxt = document.getElementById('title'); titlecheck=titletxt.IndexOf("website.com"); if (titlecheck>=0)...