javascript

Check if a variable is a string

Hi there, I am currently using the isNaN function to check if my variable is a string or an object. I just wondered if this is the wrong way of doing it because it does not seem to be working. if(isNaN(element)) element = document.querySelector(element); At the moment even if element is an object it is still causing isNaN to retur...

refresh child window from parent window

Using JavaScript i have the refresh button in my parent window, when i click refresh button , i want to refresh my child window , window.location.href='add_billing_order_frm.php?session_re_genrate=new This snippet redirecting the page instead refresh , I thing there is a snippet like opener.document.location.reload(true...

Javascript: Remove different option-tags from a dropdown list depending on another dropdown?

Yeah, the title is a mess. Here's what i'm trying to do: I have one main dropdown list where i can choose between, let's say, two options. Option1, and Option2. If Option1 is selected, i don't want anything to happen. If Option2 is selected, i want to remove one option-tag from another dropdown list. <select name="main_dropdown"> <...

jquery extract <meta property="og:url"

Hi is it possible to extract the meta data from a page loaded via ajax. I tried $("meta") as my selector but it doesn't work? Any help would be greatly appreciated. A this is my code $.ajax({ url: obj ,success: function(responseText){ var $response=$(responseText); console.log($response.find("meta").html()); } }); ...

Not Sure It's a bug on Chrome Browser.

Hi guys~~~~~ I got about javascript console to display date problem using Chrome v7.0517.41 browser(not sure if it is a bug) and OS is WinXP SP3. In javascript console, i type console.log(new Date()); then display : Sat Oct 30 2010 22:49:57 GMT+0800 (China Standard Time) //it's now on local time I change system time to +1 month ...

JQuery with HTML imagemap

I can do something like this: $(document).ready(function(){ $(".schedule_link").colorbox({width:"95%", innerHeight:344, iframe:true}); }); to attach the colorbox to a link ... <a class='schedule_link' href="index.html">Schedules</a> ... but what is the syntax to attach it to an imagemap like this? <map name="mymap"> <area s...

Create a new file and write text in Javascript

Hello, I have a website on my own Windows Server 2008 R2. On it a user can write a text on a textarea, hit "Create file" and then: function myFunction() { var s=""; var dict = {}; var data = (s + "").split(""); [...] // More Javascript stuff here } There is a default file on my server called default.js which content ...

Plotting locations on a map at city-scale

Hi, I want to plot a location on a map using the lat/lon pair reported by recent browsers. I've got that working with an image of the earth (like Google Maps zoomed out full) but what I'd really like to do is plot the lat/lon pairs at a more zoomed in level, like a ten mile radius from your current location, for example. At the moment ...

PHP disclaimer script

I was wondering: what is the PHP equivalent of this JavaScript code: window.onload = initAll; function initAll() { document.getElementById("redirect").onclick = clickHandler; } function clickHandler() { if(this.toString().indexOf("wapcreate") < 0){ window.location = "ex.html"; } return false; } I want to get all the ex...

[javascript] how ti limit the additions field?

Hi, If someone here is willing to help me I would really appreciate how to limit the addition of columns in the following html code, let say only up to 5 only? <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="friends" <table width="100%" cellpadding="10" cellspacing="0" id="my_friends"> ...

Use jQuery to control video tag

So, I want to use a jQuery function to collect a URL from a link's REL, and pass it to a element. Collecting the REL and sending it to the is no problem... but what's required to trigger the element's load and play functions, from jQuery? Here's what I have so far: $(function(){ $('a.componentLink').click(function() { ...

Avoiding messy browser's death

During the past few months, I've been working on a large web application. Repeatedly, we've written code that, according to DOM & JS specifications, should work perfectly, but still manages to completely kill one or more of our test browsers -- recently, we produced pure JavaScript code that should have been harmless but causes General P...

Webkit IDOMNode to JSObjectRef conversion

I need to convert IDOMNode to JSObjectRef somehow in the UIdelegate of my application. Any ideas ? Thanks. ...

Find + replace content of an element without loosing events.

Hi, I have a function that reads the content of an element, replaces a word with a link and then rewrites the content back into the element, obviously this means that all events that where previously set are lost. Does anyone know of a function/method that could find and replace content of an element without loosing the events? Thanks. ...

How to call a function when clicking a dynamically generated link, using jQuery?

I am creating more than 1 <a href="#"></a> elements dynamically. The id attribute is also dynamically assigned. Like <a href="#" id='delete"+id+"'></a>. ID will becomes like delete01, delete02, ... I want to call a function when clicking any one of these element. I just know, $("#someId").click(this.someFunction()); calls the functio...

How do i filter data and populate combobox in javascript

Hi guys, I am thinking to work on two combos for: country and city. When user selects country in first combo, its cities should be populate in the city combobox. For it: 1.) Prepare 2 javascript variables: first one with countries id and name, second one with cities id, name and country_id For Countries: [ {"id":1, "title":"uk"}, {"i...

Calculate age in JavaScript

Hello! How can I calculate age in years from a date of format YYYYMMDD to today. Is it possible using the Date() class? Thank you. EDIT: I am looking for a better solution than the one I am using now: var dob='19800810'; var year=Number(dob.substr(0,4)); var month=Number(dob.substr(4,2))-1; var day=Number(dob.substr(6,2)); var today...

jQuery find/replace without changing original text

Is there a way in jQuery to find a string of text in jQuery and not replace it with something else but wrap that text with an element so when the script is finished it spits out the original text with the string of text wrapped. Example: Original Text "Hello world to all people" Search string "world to" Replace with <i></i> Fina...

Optimize SVG game

I have created my first SVG game, using Raphaël.js. In Chrome the game feels fast, but in other browser like IE (understandable since it's using VML), Firefox, iPad safari and others, it feels slow at times. I'm looking for some tips on how I can optimize my code to squeeze out the absolute best performance. I've tried the best I can t...

Webkit animations performance on IPad

Do webkit based transformations/animations affect JS performance on the IPad? Is there a separate graphics processor to handle the webkit stuff? Basically I am developing a program with some simple webkit animations, but a bunch of them, and I think I have to pull out the animations because its making the Ipad slow. ...