javascript

preview of Div Content

In my Code, one main div is there. main div's width and height is fixed. and I want to create the preview of the content of main div. what should I do to create preview of Div ?. <div id="imageContainer" style="width: 680px; height: 482px;" align="center"> innerHTML Content. Another divs, images etc... </div> I have minimized the he...

standard debugging way for javascript/jquery

This is my usual way to debug javascript. Include alert(0); to break the flow and find out what is happening. sometimes when i need multiple check points i do alert('the flow is now in function 1'); alert('the flow is now in function 2'); or sometimes just alert('success'); i would like to know if there is any standard way for de...

Validation of textarea

How to validate a textarea in a form.i.e, it should not be empty or have any new lines and if so raise an alert <script> function val() { //ifnewline found or blank raise an alert } </script> <form> <textarea name = "pt_text" rows = "8" cols = "8" class = "input" WRAP ></textarea> <input type=""button...

How the addon of the firefox is accessing the file sytem

firefox wont allow the javascript to save a file in client machine is the browser security policy https://addons.mozilla.org/en-US/firefox/addon/1046 the above linked addon can save a file then why cant we save a file in the filesystem using javascript ...

Chrome error with NO_MODIFICATION_ALLOWED_ERR DOM Exception 7

I have below code to insert a style into DOM (there is a use case for injecting style into DOM so please don't ask why or say to load the css in .css file). <script type="text/javascript"> window.onload = function() { var bmstyle = document.createElement('style'); bmstyle.setAttribute('type', 'text/css'); var styleStr = "#te...

remember the highlighted text in html page(add annotation to html page)

Hi, I have an HTML file, i am opening it with webkit,i want to develop an app, such that after opening it, i should be able to select some text and make it highlighted(say by pressing some button 'highlight text' ). And it should remember the highlighted text so that when i open it next time it should highlight the same text automatical...

JSON undefined in IE7

Hey, I am using the following line of JQuery code: $.get('/ajax/buy', {'categoryname':chosenSelected}, function(data) { data = JSON.parse(data); ... However, when running it on IE7 I get error msg "JSON undefined:". How can I use the parser with compatibility to IE7 (and all major browsers)? Thanks in advance, Joel ...

GWT: forward user to a URL

Really simple question: From within GWT I want to forward the user away from my GWT page to a certain URL. What is the best way to do this? ...

jquery-ui Dialog: Make a button in the dialog the default action (Enter key)

In a jquery modal dialog, is there a way to select a button as the default action (action to execute when the user presses enter)? Example of jquery web site: jquery dialog modal message In the example above the dialog closes when the user presses Esc. I would like the "Ok" button action to be called when the user presses Enter. ...

Is there Google Hosted Version of these jQuery plugins?

Hello Could find the google hosted version of javscripts timeago.js - timeago: a jQuery plugin, version: 0.8.2 jquery.popup-min.js - ColorBox v1.3.6 - a full featured, light-weight, customizable lightbox based on jQuery 1.3 ...

Can a Client Link to My JavaScript, Hosted on a Different Domain?

Is it possible for me to supply a client with a snippet of HTML which contains a reference to a javascript file that I host? They want to paste this HTML into their CMS, so that when their page loads, it'll load our content. I was under the impression that there was cross domain security preventing this from being possible. What if, i...

How to create imaged scrollbars

Hello, How to create imaged scrollbars, for example: http://www.openstudio.fr/jquery/index.htm Basically, I want to create my own image slider with JQuery but I don't want to show default scrollbars. Instead, I would like to have imaged scrollbars. How do they create custom scrollbars? ...

where to place browser event (resize/scroll) detection call

I'm trying to alert a message when the browser is resized or scrolled. I'm detecting the 2 events in the body <body onResize="doDisp();" onScroll="doDisp();" > where doDisp is this inside the <script> tag <script type="text/javascript"> function doDisp(){ alert("browser changing state"); } </script> but isn't it bad prac...

converting a javascript string to a html object

Hi everyone, can I convert a string to a html object? like: string s = '<div id="myDiv"></div>'; var htmlObject = s.toHtmlObject; so that i can later on get it by id and do some changing in its style var ho = document.getElementById("myDiv").style.marginTop = something; Thanx a million in advance, Lina ...

How can I use JavaScript to match a string inside the current URL of the window I am in?

Hi, I have used the excellent gskinner.com/RegExr/ tool to test my string matching regex but I cannot figure out how to implement this into my JavaScript file to return true or false. The code I have is as follows: ^(http:)\/\/(.+\.)?(stackoverflow)\. on a url such as http://stackoverflow.com/questions/ask this would match (accordin...

jquery add and remove class problem

I'm trying to bind a function with a non-existent class. I will try to explain my js: function hidelink() { $('#user_form').hide(); $('.selected').text("New User").removeClass('selected').addClass('unselected'); return false; } function showlink() { $('#user_form').show(); $('.unselected').text(...

Trigger Div Click From Link

Hi all I have a site http://www.thebalancedbody.ca/ and there is a pop out contact form on the left (Contact) which has this id <div id="mycontactform">. There is also a link in the footer called CONTACT US <a href="#" title="CONTACT US">CONTACT US</a> and I need this link to trigger the pop out contact form as if the contact tab ...

AJAX Callback and Javascript class variables assignments

I am trying to build a little javascript class for geocoding addresses trough Google Maps API. I am learning Javascript and AJAX and I still can't figure out how can I initialize class variables trough a callback: // Here is the Location class, it takes an address and // initialize a GClientGeocoder. this.coord[] is where we'l...

How to calculate the curve of a linear floating point number in Javascript?

How do I calculate a curve of a linear floating point number (0 to 1) and get another floating point number as a result? What I want is up until the half (0..0.5), to be inversed logarithmic and high than that to be logarithmic like a curve according to the given linear value. ...

Strings in array are no longer strings after jQuery.each()

I'm pretty confused with the behaviour of arrays of strings when I loop them through the jQuery.each() method. Apparently, the strings become jQuery objects inside the callback function. However, I cannot use the this.get() method to obtain the original string; doing so triggers a this.get is not a function error message. I suppose the r...