Coupling two external links

Hi

I have a web-page which results from the adding of sidebars to an original pop-up. The pop-up had an external link and the one of the sidebars has an identical external link. Both are redirected via an internal file.

<a href="javascript:anchor.click()">

<a id="anchor" href="/request/index.php?id=CrowneCoogee" target="_blank">

I do not want two identical links in the same page, and decided to use an anchor to connect the two. I have two scripts but unfortunately none is perfect. The one above does not work with Safari; while the other, below, creates a dark veil in some of the browsers. The reason for this is that at the end of the external url it adds #anchor.

I am looking for a way to remeove that “#anchor” from the end of the url. The script that does not work with Safari does not append anything to the end, so I assume that a solution can be found.

<a href="javascript:void(0);" onclick="_Link('anchor')"><an image</a>

and below

<a id="anchor" href=/request/index.php?id=CrowneCoogee/" target="_blank">

function _Link($a) {
	if(!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)) {
		document.getElementById($a).click();
	} else {
		var $e = document.createEvent('MouseEvents');
		$e.initMouseEvent('click', true, true, window);
		document.getElementById($a).dispatchEvent($e);
	}
}

I am looking for a way to remeove that “#anchor” from the end of the url. The script that does not work with Safari does not append anything to the end, so I assume that a solution can be found.

Unfortunately, with so many changes trying one thing and the other, I’ve mixed the code… and with this last code I am getting the home page, which means that it is not addressing the correct url in the intermediary file

Many thanks

Mybe it would help if I give you the page in question:

http://pintotours.net/Work/JKT/CrowneCoogee.html

Hi,

Assuming I’m on the page you link to, how can I reproduce your problem?

Hi

You have 2 Crowne Plaza logos. Both should take you to their website. From the right sidebar, vua the bottom sidebar anchor and then via the internal redirects.

My first problem is that I mixed up the code and now instead of gettong the right url, it is picking up the default which is my index page.

Once we get that working again, then the main problem is to make sure the url of the hotel goes without anything added to it.

Why are you doing this with JavaScript?
Wouldn’t it be easier (and much more accessible) to just add the appropriate urls to the anchor tags.

i.e. don’t do this:

<a href="javascript:void(0);" onclick="_Link('anchor')">
  <img src="/Pinto/Logos/CrowneLogo.jpg" width="130" height="130" title="Crowne Plaza website">
</a>

do this:

<a href="www.linktowherever.com">
  <img src="/Pinto/Logos/CrowneLogo.jpg" width="130" height="130" title="Crowne Plaza website">
</a>

That’s the whole point: I don’t want to repeat the url

It may sound silly but that is what I want to do.

Lol. Why on earth not?

One affiliate code in one page is too much. Two…

Anyway, that’s what I want to do, if you can help. The basic code is already there but as my knowledge of js is NIl, if you can help put the last code together, I would be grateful.

Sure I can help, but I need to comprehend what you are trying to achieve.

To summarize: you have two images (the Crowne Plaza Logos). These images should both link to the same page (the Crowne homepage), but you don’t want to write:

<a href="www.linktothecrownehomepage.com">
 <img src="/Pinto/Logos/CrowneLogo.jpg" width="130" height="130" title="Crowne Plaza website">
</a>

Is that correct?

Thta’s right.

The logo on the left should rely on an anchor to the one in the middle (or vice versa). The actual link is in a redirects.txt file that keeps hundreds of urls

You’ve lost me.

It would be simple to obfuscate the link using JavaScript, but I have the impression that I’m missing something.

I have to turn in now anyway (it’s late), so maybe someone else will be able to help.
If not, I’ll check back again tomorrow.

Thanks

I’ve just discovered the error: a missing quote… and a # that should not be there.

Everything seems to be working now.

RESOLVED

Until your first visitor with JavaScript turned off where the links are then broken.

You should never use JavaScript for navigation without also providing a fallback for those without JavaScript.

Hi felgall

If a visitor has jave turned off, in 99% of cases he/she is not interested in adverts and affilite links. So, I will not miss him.

How often fo you click on affiliate links?

Hi felgall

having re-read your post, I see your point!

Something to think about.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.