I want to use an anchor tag to invoke some javascript and I've read that it's bad form to use <a href="javascript:foo()">
I've read endless usenet posts and hint sites on the net, they all suggest different things and I can't get any kind of consistency, and I can't find any solution that works properly for IE, opera and mozilla.
many of the recommended solutions go something like this:
<a href="javascript:void(0);" onclick="foo()" />
this generates an <a> that looks like a hyperlink (good) and it invokes foo() as well (also good). the problem is that if in function foo, I put
window.location.href = "some new url";
it just seems to get ignored. If I miss out the href altogether, the link works but it's not formatted as a hyperlink.
All I'm trying to do is make something that looks like a normal hyperlink but whereby I can build the URL with some javascript rather than having it coded into the HTML, and I have to say it's driving me mad!!.
I am currently recoding my website to perform more efficiently. By performing more efficiently I mean that I will be recoding the server side mostly.
One Particular idea I had was for select boxes. Right now for a page that lists the information for a user (say country of birth for example, which has over 200 option values) the php has to print all the values of the countries in a loop as <option></option>. The reason why it has to print them out each time is because it has to select the users country name.
Considering that there are 200+ values and there are also about 8 other select boxes that also have their information to be selected and printed thru php loop, it can get to be quite a strain on the CPU (when a bunch of users are all doing it).
So I decided to use a javascript function for each box to select the correct option value to be selected according to what the user has chosen beforehand. It generally is the same thing only the client is doing the job and not the webserver.
So what I am asking here is that should I reply on the javascript to do this? I have the paranoia that there will be some occurances where the client doens't have javascript or the version of javascript wont support the DOM features that are used to perform the job.
So for the average browser to be doing something like this, should I still be worried about this or should I go back to using the server side to handle the selected box values???
I work on a portal website that has approximately 700 pages and several thousand links.Some of these links are to various documents (.doc, .pdf, .xls). I would like to use Jquery to dynamically find these links on a page when the pages load and add another link directly after it that can invoke a modal window. When the modal window opens I need to hold onto the values of the original link as it will be stored in a DB. So I think I will need the second link to contain the first links name and URL pattern as some sort of property that I can store. I am not sure the best way to accomplish this. For example:
e new to jQuery and have a question. I'm populating a table with rows where some of the columns include links and buttons. For some of these links and buttons I want to run some jQuery stuff before it's redirected (acually, I want to have the result loaded in a div via ajax). In the jQuery function I want to be able to extract the ID of the button or the href target that was clicked.
Iīve gone thru a few exaples of the 'hello world' equivalent for ajax; the classic example having main.html with div id="main_panel", then having ON THE SAME folder of the main.html file, the few files for getting via ajax and then render itīs content inside div id=main_panel and so on, happy with that;my question is: All of those examples, always get those 'few files', lets say, one.html, two.html, and so, in the same folder where main.html resides; I want to achieve to have the 'some files' in a different folder, letīs say, /editors/ relative to the path where main.html is; Iīve done this, the ajax call works fine; the PROBLEM is that the xmlhttpresponse (consumed ajax text) wich is basically html 4, changes the links (hrefs) in those to the path of main, letīs say, for example, one.html has a link that points to itself, not an anchor, just a link pointing to itself as we often use for pagination of a grid, well, that link href attribute is changed to the path of the main.html file, and not preserving the original href attribute... why? where should I start from? changing the context parametere prior to calling ajax get?
Currently I use an onbeforeunload method, to do call various tidy up methods when a user exits my web application - however I now need to add additional support, for users migrating to Sun's JVM.
My understanding that the onbeforeunload call is a Microsoft one, and the net result of having it in a page used by a SUN JVM user is that the browser does not close.
Does anyone know of an alternative to this method, that is supported by Sun's JVM?
In my webpage I have an embedded Windows Media Player and an unordered list with a table of contents.
When playing a video, the Windows Media Player is triggering events for new 'chapters'.
The corresponding chapter in the unordered list is then highlighted with css.
The list can contain up tot 100+ items. Because the page itself should fit the screen without scrolling, i put the list in a scrolling div.
I also want the div to scroll automatically in order to keep the current chapter inside the visible scope of the div.
Right now i do this by initually creating an anchor for each listitem. When an chapterswitch event occurs i scroll to the corresponding chapter with the folling line of Javascript code:
window.location = "#" + ListItemId;
There is one problem; the annoying tick sounds in IE. For my application it is not rare to have 25 'chapters' switched in one minute, so that's an awful lot of ticking.
I was wondering if it is possible to automatically scroll up or down to a specific point in a div without the browser making any sounds.
I was wondering if anyone can help me? I am having some problems wit the <noscript> tag.
I actually use it to block banner advertisements from being displaye in my website. I have used it at the <body> tag section and look something like this:
<noscript> <body> </noscript>
What it does is stop the banner advertisement offered in most fre websites from loading.
My question is how come it does not stop the banner from loading if was to view the webpage in my Pocket PC using Pocket Internet Explore Pocket IE)?
Everytime I load the page in Pocket IE, it displays a standard banne that is found in all pages viewed using Pocket IE. I looked around fo some answers and I found out that Pocket IE found in the Pocket PC 200 does not support the <noscript> tag.
Is there another way around this? I have written some pages that wil load in my Pocket PC and I find it very annoying to see the banne advertisement at the top. Code:
I was wondering if there was an addLoadEvent alternative, that could be used before all images are loaded? I think it's something like when the DOM is ready...
Code: var tabs = new Control.Tabs('menu'); var pattern = 'tab='; var nStr = location.href; if(nStr.match(new RegExp (pattern,'gi'))){ var id = nStr.split(pattern);
[Code]...
It searches for the query string 'tabs=' and then splits the result to get the id of the tab. Then it uses this to set the active tab. If the url doesn't include the query string it set the tab to the first one.
The code works but it uses Eval to convert the id string (id[1]) to a variable and I was wondering if there was an alternative.
Is there a more concise way to do something like the the desired code below?
The gripe is with the try-catch syntax. It takes *way* too many lines of code to evaluate a conditional expression when zero or more parts of the conditional expression may trigger an error. In this case, the trigger is a call to a non-defined (null) object.
In other words, how can you do a more simple 'try' statement that simply spits out true or false, depending on whether the 'tried' code threw an error or not?
Defining a function don't seem to work because you can't pass the 'try' code as an argument. Extending the 'Global' constructor is not an option, so now what? Code:
I'm working on integrating the a javascript wysiwyg editor (Xinha) with my blog software (ExpressionEngine, aka EE). EE has extensions now so it's easy to get the Xinha header code into the head section of the EE web page.
But Xinha likes to use an onload command to launch:
window.onload = xinha_init;
....and EE is already using the onload command in the body tag of the web page:
I have a query on browse button, In my page , i want to upload files , But i dont want normal <input type=fileto be used for this, so can anyone tell me anyother alternative solution for this , Here I have a button and textbox, if i click the button, it should popup a file upload dialog box ,after selecting a file, that path should be pasted in that textbox...
I'm looking for an alternative for .closest(). My script refers to jQuery 1.3.2 which is not the latest, but does its job. By trying to implement my code into another script I noticed that this script uses jQuery 1.2.6. Well, 'changing that version was no option'.[code]This is my code. It should be used to clone special comments containing "In[" and in some cases "text".Unfortunately .closest() doesn't work out for me. i'm looking for an alternative.
Is there a javascript or jquery effect which can simulate the effects in flash shown on this page : http://www.macrolane.fr/Temoignages/Effects are on mouseover and mouseout on the squares
my website tag7.ch consists of an html entry page and the main website. on the entry page there is a js menu that opens the main webpage in a new window in full screen. I love this function but browser that dont allow js doesnt have a chance to enter the main website.Do you know how the script has to be changed that there will be displayed some simple html text-links for non-js browser?greetings from switzerland,marcuswww.tag7.ch
<head> <SCRIPT LANGUAGE="JavaScript"> function openPage(page, width, height, sBar) {
I have this code http://www.jsfiddle.net/Nntc7/ created by a pdf publisher, I need to offer non flash content to users but dont know javascript and I cant get the thing to work using swfobject, How do I edit this to allow for alternative content??
I need to detect the "name" of the constructor of an object. For example, myArray.constructor === Array is true, but I want something where that === 'Array' is true. I've heard of Object.constructor.name, but it's not widely compatible. (preferably without involving regular expressions)?
It appears that the html method isn't available with XML. Is there an alternate method I can use to grab a whole chunk of HTML within a portion of my XML document?
So I have a set of <SELECT> elements that are ajax'd in and out depending on what is selected using the event "change". I know that .live("change") is not fully supported.
The code works, but it obviously can't be used for more than one picture per page because getElementById finds the first div and always displays it onmouseover of any attempted mouseover text.The Javascript in <head> is
<script type="text/javascript"> // Pop up code begin function ShowPopup(hoveritem)
I just want to be able to have more than one instance on each page and still be able to declare the image url in the body and not within the javascript.