Alternative To Javascript Hrefs

Jul 20, 2005

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!!.

View 6 Replies


ADVERTISEMENT

<SELECT> Javascript Alternative

Mar 29, 2006

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???

View 2 Replies View Related

JQuery :: Dynamically Add Link After Certain Hrefs?

Jun 15, 2009

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:

[Code]...

View 2 Replies View Related

Change All The Hrefs On A Single Page

Jun 30, 2010

Ok so i'm trying to write a Greasemonkey script to change all the hrefs on a single page. The href by default looks like this:

<a href="javascript:get('246154895')" class="postid">ID</a>

What i'm trying to do is make the number from get() appear in stead of "ID". How should i get this done? I started up with this:

var posts = document.getElementsByClassname('postid');
for (i=0; i<posts.length; i++) {
//Replacing
}

But i doubt it will work, since there are other items with the class "postid" that aren't related to these tags i'm trying to change.

View 5 Replies View Related

JQuery :: Binding Hrefs In Table Entries?

May 2, 2009

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.

[Code]...

View 1 Replies View Related

JQuery :: Xmlhttpresponse - Consumed Ajax Text - Basically Html 4 - Changes The Links - Hrefs

Apr 24, 2011

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?

View 1 Replies View Related

Better Alternative For RSH?

Mar 16, 2010

I have been using RHS, but in IE, it sometimes doesn't work the way I expect. Also, last update was a long time ago.

So, does anyone know better alternative for RSH?

View 3 Replies View Related

OnBeforeUnload Alternative

Jul 23, 2005

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?

View 4 Replies View Related

Alternative Scrolling

Sep 30, 2005

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.

View 3 Replies View Related

Alternative To <Noscript>

Jul 20, 2005

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:

View 2 Replies View Related

Alternative To Anchor URL?

Feb 28, 2011

Is there an other way to link to an element on the same page without using anchor URLs?

View 18 Replies View Related

AddLoadEvent Alternative?

Dec 7, 2006

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...

View 1 Replies View Related

Looking For An Eval Alternative?

Aug 29, 2009

this is the code I'm working on:

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.

View 2 Replies View Related

A Better Alternative To Try Catch Block?

Jul 23, 2005

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:

View 3 Replies View Related

String Replace Alternative

Jul 23, 2005

Is there a possibility to do a string replace in javascript without regular experessions. It feels like using a hammer to crash an egg.

View 24 Replies View Related

Alternative To Using Onload Command?

Jan 28, 2006

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:

<body onLoad="document.forms[0].title.focus();set_catlink();" >

The onload command in the body tag is keeping the window.onload command
from working. At this point EE doesn't let extensions modify the body
tag.

Is there an alternative way to run the xinha_init command, without using
the window.onload command?

View 3 Replies View Related

Is There Any Alternative For Browse Button

Apr 12, 2007

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...

View 2 Replies View Related

JQuery :: Is There Any Alternative For .closest?

Oct 5, 2010

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.

View 1 Replies View Related

JS Alternative For Following Flash Effects?

Jul 14, 2010

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

View 1 Replies View Related

Add A Textbrowser Alternative To This Js Menu?

Jan 28, 2009

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) {

[code]....

View 4 Replies View Related

Alternative Content For Non-flash?

Jul 26, 2010

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??

View 4 Replies View Related

Alternative To Object.constructor.name

Feb 9, 2010

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)?

View 4 Replies View Related

JQuery :: Alternative To Html() For XML Documents?

Aug 6, 2010

I am retrieving an XML document like the following:

<SampleData>
<contentContainer>
<div>HTML goes here</div><div>HTML goes here</div>
</contentContainer>
<moreRecords>1</moreRecords>
</SampleData>

I was using a statement like this to take the content out of the "contentContainer" element and place it into another element:

$('#myDiv').html($(newXML).find("contentContainer").html());

This works great in Firefox, but doesn't in IE. I can use the following in IE using the text method, but that doesn't do what I want:

$('#myDiv').html($(newXML).find("contentContainer").text());

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?

View 1 Replies View Related

JQuery :: Alternative To Live (Change) In IE6

Jun 18, 2009

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.

View 2 Replies View Related

GetElementById Alternative For Multiple Instances?

Apr 23, 2010

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)

[code]....

So the display code is

<a id="hoverover" style="cursor:default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();">text here</a>
<div id="hoverpopup" style="visibility:hidden; position:absolute;"><img src="url here"></div>

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.

View 8 Replies View Related

DXHTML Alternative To Script-compiled CSS

Apr 17, 2003

I often script-compile CSS, like:

var sty='<style type="text/css">'
+ 'p { color:red; }'
+ '</style>'
document.write(sty);

How can I do that without document.write?

View 15 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved