javascript

js - using replace method to replace html element

hi everyone! i have a question. I have a work this morning but i don't know how to do it. My work here (html): <div class="demo"> <p>this is demo text</p> </div> here is my JS : var tempdata = $(".demo").text(); var replacedata = tempdata.replace("text","<span>1234</span>"); Look everything ok. but result is : this is demo <spa...

Doing things depending of the action in a web page with Jquery.

Hi... Anyone know how to do this: When some user left my site by closing the browser or tab or going to other site I would like to do an action (show an alert) and if the user clicks on a link or button to other page of my own site I would like to do another action... If I use unload event I can't differentiate between these two kind ...

Problems with multiple setIntervals running simultaneously

Hello, My first post here. I want to make a horizontal menu with submenu's sliding down on mouseover. I know I could use jQuery but this is to practice my javascript skills. I use the following code: var up = new Array() var down = new Array() var submenustart function titleover(headmenu, inter) { submenu = headmenu.lastChild up...

Set all link targets for a page

I have links that are dynamically generated and I need to set the target for all of them. How could I do this with javaScript. I found something that looks like it should work using jQuery.. $("a").attr('target', '_top'); but I dont want to use a library for this and I imagine a couple of lines of javaScript would take care of it.....

Programmatically press "Left" key in a text input

I am trying to programmatically fire a key event to go left in a text box, but not having any luck. The input element has focus and the cursor is at the end. I'm trying to get the cursor to move left one step - before the letter "F" *programmatically by firing a Keyboard event (keydown/keyup/keypress) with the corresponding keystroke ← ...

Append more than one control to div

Ok this will be quick. I am collecting data in div by inserting hidden input boxes before i eventually submit to the server. here is Javascript code. function appendToDiv() { var mydiv=document.getElementById("somediv"); var mydata=document.getElementsByName("description")[0].value; var myurl=document.getElementsByName("url")[0].valu...

How do setBounds in Google Maps API v2?

I'm upgrading some code written for Google Maps API v2, and I wish to set the bounds of the map (top, left, bottom, right), rather than the centre. I notice that there's a GMap2.getBounds but I can't seem to find a method which allows me to set the bounds. How can I do this in Google Maps? ...

How do you access the DOM node in jquery inside of a javascript variable?

I have the following html <div id="list_item_template"><li><a href="#">Text</a></li></div> and javascript: var item = $("#list_item_template").clone(); What I want to do is access the inner <a> tag of the cloned copy and add an attribute. Without cloning I would just do: $("#list_item_template a").attr("onclick", "SomeFunction()"...

html form using input as a submit button

Hello onlookers, A web site I've been using has some interesting behavior... There is a form, but there is no button for submission. Instead, there is an input: <input id="ctl00_pageContent_loginButton" type="image" style="border-width: 0px;" alt="Login" src="images/btn_login.gif" name="ctl00$pageContent$loginButton"/> and when y...

Disabling Text field with Javascript when value in drop down box is from mysql

Hi I have a simple script in HTML, using a dropdown menu. When the value 1 is selected, the user can write in the text field, if value 2 is selected, it disables the text field. However, i changed the values of the dropdown menu, so that one value was from a mysql table(using PHP) and the other remained 'option value='1''. Yet now neit...

Help with google maps api, user allowed marker map

Without telling everyone too much about my new idea for a website, Pretty much I need help, maybe someone can help write it up, with a site that has a simple map that allows any user to double click the map and make a marker. When the marker comes up I just want Title and Description available for edit(only once, so others cant chan...

From client, force whole page validation

I have an ASP button for which I have set the OnClientClick property to display a javascript confirm message. However, I only want this message to be displayed AFTER all of the client side validations have passed. How can I do this? Essentially, I believe that I need to force Page level validation from the client and then, only if it p...

Jquery click bindings are not working correctly when binding multiple copies

I seem to have an issue when creating copies of a template and tying the .click() method to them properly. Take the following javascript for example: function TestMethod() { var test = Array(); test[0] = 0; test[1] = 1; test[2] = 2; // Insert link into the page $("#test_div").html("<a href=\"#\"></a><br>"); ...

invalid property id error while passing data in json format

I have a some data in JSON format(which comes from php) to be passed to a javascript function. I'm getting 'invalid property id' error when I try to do this. Error: invalid property id Source File: http://localhost/MathVoyager/index.php/test Line: 1, Column: 15 Source Code: draw_quadratic({ Below is the js function signature(both data...

adding newly created dom elements to an empty jQuery object

Why doesn't this work in jQuery 1.4.2? var $list = $([]); for(var i=0; i<50; i++) { $list.add( $('<div/>', { id: 'jake', class: 'test' }).data('test', { hi: 'hello' }) ); } alert($list.size()); // 0 Thanks! ...

Closing a Dialog Box, Opening a New One and it is Grayed out (Colorbox)

$.fn.colorbox({width:"40%", inline:true,href:"#somediv", opacity:"0.50",transition:"none", height:"490px"}); On #somediv above I have a button that once clicked executes the following code: line#45 $.fn.colorbox({href:"http://www.facebook.com", width:"65%",height:"80%",iframe:true}); I see facebook.com however the overlay is grayed ou...

can anyone please suggest some simple and short js for vertical multiple text scroll???

I have a js running in my site that is for text scrolling.What is does is that it scrolls a text vertically upwards then holds for a second or two and then shows next text.Here you can have an idea of what i need and im using http://www.dynamicdrive.com/dynamicindex2/crosstick.htm What i need now is a simple and shorter dynamic js for t...

how to increase Speed of a component made from Javascript or JQuery ?

I want to make my component faster, I am using Javascript and JQuery to build that. I am using JSON object to communicate with component and back-end is python. Is there any suggestion to make component faster? ...

how to get values sent by location.replace(URL)

hi everyone, In my JavaScript function I do like this in order to redirect parameters to servlet: var ids1=document.getElementById("projet").value; document.location.href("http://localhost:8080/Opc_Web_App/ServletAffectation?ids1="+ids1); and in the servlet I do the following to get Value: String idprojet= request.getParameter("ids1...

How can I split my conkeror-rc config over multiple files?

Short version: can you help me fill in this code? var conkeror_settings_dir = ".conkeror.mozdev.org/settings"; function load_all_js_files_in_dir (dir) { var full_path = get_home_directory().appendRelativePath(dir); // YOUR CODE HERE } load_all_js_files_in_dir(conkeror_settings_dir); Background I'm trying out Conkeror for web ...