Forum Moderators: open
In the JavaScript I am using this code to redirect the visitor, which works fine in IE:
<SCRIPT LANGUAGE="JavaScript">
function startClick() {
myLink.click();
}
</SCRIPT>
The event is triggered in the BODY tag:
<BODY OnLoad="startClick()" ... >
The page redirects upon loading in IE, but not Firefox - does anyone know how to fix it to work in both? Or a workaround/alternative solution?
Many thanks in advance!
1. Get the href from the link, and relocate:
function startClick() {
window.location.href = document.getElementById('myLink').href
}
2. ..but you might as well just hard-code the URL
window.location.href = 'target-page.html';
3. While you're at it. If this is a redirect, it will be less irritating if you remove the redirecting page from history, or the user will be stuck without a sensible back button:
window.location.replace('target_page.html');
It's important for tracking at the destination site, but if log files will track the code you provided as a "click" then it should be okay. (Sorry, I don't know much about how web servers track referrers/clicks, etc. in log files)