javascript

How to interpret javascript code sent via ajax?

hello, I have javascript code embedded inside a html template file. When I load this template via ajax and inject it into the DOM, the javascript code isn't functional. Would anyone know how to get this javascript code to execute as normal? Thanks a million! ...

JavaScript: Container with draggable. Constrain draggable to a circle shape, in container.

Hey guys, I'm looking for a simple solution to place a draggable element inside of a box container. When the user begins to interact with the draggable, the draggable element should remain constrained to a circular shape, within the container. At a complete loss as to how I should accomplish this. Thank you! :-) Additional: Box co...

Use of 'this' keyword javascript in IE ?

Is there a workaround for Internet Explorer to implement the functionality offered by 'this' javascript keyword to get the dom element that triggered the event? My problem scenario is : I have a variable number of text fields in the html form, like <input type="text" id="11"/> <input type="text" id="12"/> .. I need to handle the...

jQuery: How to remove this code redundancy?

clone.find('[id]').each(function() { id = $(this).attr('id'); ind = id.search(/\d+$/); $(this).attr('id', id.substr(0,ind)+id_counter); }); clone.find('[for]').each(function() { id = $(this).attr('for'); ind = id.search(/\d+$/); $(this).attr('for', id.substr(0,ind)+id_counter); ...

Creating <li> with JavaScript in an XUL Application

Hi! I try to create some li elements in my XUL Application. Theres only the text of the elements shown, but no list typical bullets and linebreaks. Example: text text text text text text text Heres the JS Code I use to create the list: var li = document.createElement('html:li'); var txt = document.createTextNode("only shown as ...

Attaching a function to the parent window from an iframe and getting proper scope

I working on adding file uploading to my web application. I'm using an iframe to post my upload. When my php script processes the upload it writes some JavaScript to the iframe. This JavaScript is attempting to attach a function to the parent, this works, but when this function actually gets called it doesn't have the correct scope. Here...

How to change HTML background with JavaScript Function?

How to change HTML background with JavaScript Function? I need some simple function to change background from one image to another? ...

javascript to select text from web page

I'm trying to write a bookmarklet that grabs any selected text on a web page and sends it to my website. It should (hopefully) work in Chrome, FFX, Safari, and IE. I did a search and found a function, but it doesn't appear to work. Here is the code: <html> <body> <div onClick=getSelText()>Click</div> <div>please select me</div> </bod...

Display alert msg in web page when forwarding from one page to another on page load.

I have created a html page in php and upon submission i validates that page using PHP. After validating i want to show an alert msg to show its status like showing any greeting or request for re-enter. I have dont validation. Now i m using header( 'Location: http://localhost/assignment/WebForm.htm' ) ; to redirect user to same page ...

How to find all files in directory? (HTML JavaScript)

How to find all files in directory? I have HTML page in some directory. Using JavaScript I want to get all existing files in some subdirectory ( get all file names or relative links to them, on a local machine) ...

Why can't I do this in a function?

function focus(element) { document.form.element.focus(); } I want to have a function to focus on an input box, but it seems I can't do that. Is there a better way to do this? ...

clearTimeout not working in javascript autocomplete script

I am using the following code as part of an autocomplete script to avoid hammering the server with every keystroke: var that = this; textInput.bind("keyup", function() { clearTimeout(that.timer); that.timer = setTimeout (that.doStuff(), 2000); }); Unfortunately, this does not clear the old timers. They still all execute. ...

Can I pop up alert in javascript using php.

I want to trigger javascript alert using PHP. Is it possible I want to use it in head section, for displaying it at load time. <head> <?php $valid="valid"; if(!isset($valid)) echo "<script type=\"text/javascript\"> alert('Hi');</script>"; ?> </head> EDIT i want to display javascript alert() at load ...

JavaScript Prompt - Is it ok to use? Or does it act strange in some browsers?

I'm interested in using a JavaScript Prompt to have the user enter data. Any concerns on using JS prompt? Will any browsers freak out? ...

Var null and not an object when using document.getElementById

Hi, I'm doing some work in HTML and JQuery. I have a problem of my textarea and submit button not appearing after the radio button is selected. My HTML looks like this: <html> <head><title>Publications Database | Which spotlight for Publications</title> <script type="text/javascript" src="./jquery.js"></script> <script src="./addSpo...

Check in Javascript if a SSL Certificate is valid

Hi. Is there a way to check in Javascript if given a host it's SSL certificate is valid? (non blocking) In my case I want to display: "you can also use https://.." if via javascript I can make a request to https://my_url without being asked to accept an untrusted certificate. Can this be done asynchonously? -- M. ...

How do I get just the x or y position of the background image using prototype?

Hey, I'm making a simple user friendly css editor using Prototype. Anyway, I was wondering whether I could get the background-position x/y values on their own? I wish I could do something like this but sadly it doesn't work: element.getStyle('background-position-x); I guess this is because position comes in different forms like 'center...

NewBie Question, jQuery: How can we implement if...else logic and call function

I am new to jQuery and so don't mind this question if it sounds stupid but here is something that I am trying to do : I have 3 functions like: AddToCart Function which adds item to the shopping cart: //offer_id is the offer which we are trying to add to cart. addToCart: function(offer_id) { }, RemoveFromCart which remove...

How do you set a cookie to be accessible across the entire domain in Javascript

I suppose there should be a way to set a cookie to be accessible from the entire domain nevermind from which directory you are setting the cookie. Say in mypage.com/blue/index.php y set the cookie "colour=blue;" this way: document.cookie = "colour" + "=" + "blue" + "; expires=" + expireDate.toGMTString() + "; path=/"; Usi...

Seeking a simultaneous fade and blur effect using JQuery or Javascript

Can anyone think of a way to simulate the fade/blur flash effect used in the following website: http://www.frenchlaundry.com/ (image fades and blurs on hover, while text fades in simultaneously) using JQuery? I am looking to have this whole chain of effects happen on load or when the DOM is ready (instead of on hover). And by blur, I ...