Thanks to Chetan Sastry I have this Regex code to parse my page for a list of words and add the TM to them.
var wordList = ["jQuery UI", "jQuery", "is"];
var regExp = new RegExp("\\b" + wordList.join("\\b|\\b") + "\\b", "g");
var $elem = $("#divWithText");
$elem.html($elem.html().replace(regExp, "$&™"));
This Regex is almost wha...
We all know that global variables are anything but best practice. But there are several instances when it is difficult to code without them. What techniques do you use to avoid the use of global variables?
For example, given the following scenario, how would you not use a global variable?
Javascript:
var uploadCount = 0;
window.onl...
I'm using the jQuery Form plugin to submit AJAX requests. It's a simple contact from using this PHP script: http://pastie.org/725652 - the only validation happens inside the PHP.
Here's my Javascript code to trigger the whole thing:
$('#contactform').ajaxForm({
target: '#error',
beforeSubmit: function() {
$('#error').a...
No thoughts on this one? Anyone?
Here is my scenario:
I have a form where the user selects a report type, and then selects a list of users they want to generate reports for. When they submit the form, a new window is opened that uses pagination to allow the user to review each user report individual by using next and previous links. ...
When researching JavaScript conditional comments for IE, I stumbled upon @cc_on. This seems to work. However, the wikipedia entry on conditional comments provides the following code for more robust IE detections, specifically IE6:
/*@cc_on
@if (@_jscript_version > 5.7)
document.write("You are using IE8+");
@elif (@_jscri...
Currently i'm parsing bbcode server side but i'd like to show a preview just like this site does.
If I process the bbcode serverside using ajax it's a bit laggy, so i thought doing it client side, to just show the preview.
Do you guys know any bbcode parser written in javascript?
...
My Spider Sense warns me that using eval() to parse incoming JSON is a bad idea. I'm just wondering if JSON.parse() - which I assume is a part of JavaScript and not a browser-specific function - is more secure.
...
i want to make a login page but it is hidden in the center of the main page.
and then i use jquery to make the div that surrounds it visible and it will be like the login page at www.bytes.com.
but i cant figure it out how to center it with css. it doesnt work without affecting the main pages div positions.
i just want it to float ove...
Hi
This I can't work out
I have ASP.Net user control,which is basically two drop downs, that has a public property Index which is calculated from the drop downs, and works fine
I need to access the value of 'Index' from javascript, but accessing via getElementById was completely wrong, can anybody point me in a better direction
Cheer...
I'm reading Douglas Crockfords Javascript: The Good Parts, I just finished the regular expressions chapter. In this chapter he calls javascript's \b, positive lookahead (?=) and negative lookahead (?!) "not a good part"
He explains the reason for \b being not good (it uses \w for word boundary finding, and \w fails for any language that...
When using Cufón the documentation recommends using the following snippet with IE in order to eliminate a small delay in rendering the replacing font.
<script type="text/javascript"> Cufon.now(); </script>
While testing it I never experienced any delay with IE7+ but the issue occur using Google Chrome. If I put the snippet on, Chrome ...
Hi,
The following code does not work for me
<body onload = "<?php
foreach($arr as $a){
echo "<script language = javascript> popup_show(\''.$a.'\', \'popup_drag\', \'popup_exit\', \'screen-top-left\', 20, 20) <script>";
}
?>" >
I even tried this with an alert .
<body onload = "<?php
foreach($arr as $a){
echo "<script language = j...
I have an html application running in IE6(yes it has to be 6 for the time being), currently I print a page/report of the application. This report is all html and just uses the browsers built in print functionality. It currently spans more that 1 page i.e. scrolls, and the printing functionality prints the whole page, even what is not v...
Hey all, I've got the following regex:
var outstring = inputsplit.join(';').replace(/\s/g, '');
the problem is, given the array:
["this ", "is ", "a ", "test"]
the output is
"this;is ;a ;test"
instead of
"this;is;a;test"
any pointers on what I can do to get this global filter to work?
...
This is probably really easy, but I've never done it before. How do you change your cursor to the finger (like for clicking on links) instead of the regular pointer?
And how to do this with jQuery since that's what I'm using it for.
...
How can I achieve this?
A user clicks the delete link (with a class of "confirm").
Confirmation message appears asking "Are you sure?" with "Yes" and "Cancel" options.
If yes is selected, the link continues as clicked, but if cancel is selected, the action is canceled.
Update: Final working code with confirm() thanks to this guy:
$...
Which is a better approach for this?
ActionScript3 or JavaScript+PHP?
And if anyone came across an open source tool with either I'd really appreciate it.. after a long search, the only good example i found was this http://www.ajax-image-editor.com but I'd rather have a flash alternative.. Also I don't need all the extra functions such ...
Hi all,
I've been trying to design a widget for my rails app and unfortunately find myself lacking in Javascript skills...
I was able to create a widget based on the short guide from this blog: http://www.eduvoyage.com/2008/8/3/widget-with-rails
But what I need is a little different from what they describe.
If you had a digg or tweet...
i have a problem in removing the old markers without removing the central point of the circle "it's also a marker"
the source ::::
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;se...
Hi all,
I currently have the following within my view
function loadData() {
var url = "/Testx.mvc/GetData";
var id = "111111";
var format = "html";
$.ajax({
url: url,
type: "POST",
dataType: format,
data: "id=" + id,
success: populateResults
});
}
function popula...