Help writting onClickRedirect and making it open on a new window

Rik9000

Registered Member
Joined
Jul 8, 2011
Messages
68
Reaction score
21
Hi,

I'm not an advanced JavaScript writer and I need this onClick Redirect to open on a new window browser, Whats missing in the code? All I have found is that to make the event open in a new page, I will have to write a window.open function, but I need the url broken in several variables and hidden from google for SEO purposes

Code:
<SCRIPT language="JavaScript">
function onClickRedirect9() {
    var url1 = "http";
    var url2 = "chat.example..com/request.php";
    var url3 = "l=admin&x=1&deptid=&page";
    var url4 = "http:://example..com";
    window.location = url1+"://"+url2+"?"+url3+"="+url4;
}
</SCRIPT>
Thank you....
 
You'd need to use the built up url in window.open instead of window.location

Replace
Code:
    window.location = url1+"://"+url2+"?"+url3+"="+url4;

with

Code:
    var url = url1+"://"+url2+"?"+url3+"="+url4;
    window.open(url, 'redirect_url','left=0,top=0,width=800,height=600,toolbar=1,resizable=0');


I might be wrong, but I don't think google reads javascript - so you might not need to break your URL up.
 
I believe you are right google does not read javascript, but I rather break it an make it harder to read cause i could get penalized by google for having a link pointing to that specific site but is essential for my website to open up the chat interface of my affiliate program....

Those 2 code lines surely solved my problem thank you very much for your time an knowledge :)
 
Hi, I was going to open a new thread with my following question but since it is very similar to the question I made above Im going to ask it here:

Ok I created several onclick events and now I will like them to be called from an external file so I can remove all that javascript from my header, I guess that having all that JS codes is not appealing to google eyes. All I found is that I should create a .js file which contains only the onclick functions something like this:

Code:
<SCRIPT language="JavaScript">
function onClickRedirect2() {
    var url1 = "http";
    var url2 = "sample";
    var url3 = "com";
    var url4 = "page1";
    window.location = url1+"://"+url2+"."+url3+"/"+url4+"/";
}

if (function onClickRedirect3()) {
    var url1 = "http";
    var url2 = "sample";
    var url3 = "com";
    var url4 = "page2";
    window.location = url1+"://"+url2+"."+url3+"/"+url4+"/";
}
</SCRIPT>
Then All I should put is the reference on the header:

Code:
<script type="text/javascript" src="onclickevent.js"></script>
And to write the onclick event use :

Code:
<span style="text-decoration:underline; color:#0066FF; cursor:pointer" onclick="javascript:onClickRedirect2()">CLICK HERE FOR PAGE 1</span>
I have done all the above but still I can not make it work... what could I have done wrong? Again Im not very skilled writing javascript and all my knowledge about it comes from the internet...
 
Your code does not work because it is not syntactically valid. Replace with this.

Code:
function onClickRedirect2() {
    var url1 = "http";
    var url2 = "sample";
    var url3 = "com";
    var url4 = "page1";
    window.location = url1+"://"+url2+"."+url3+"/"+url4+"/";
}

function onClickRedirect3() {
    var url1 = "http";
    var url2 = "sample";
    var url3 = "com";
    var url4 = "page2";
    window.location = url1+"://"+url2+"."+url3+"/"+url4+"/";
}

Script tags are not used on external .js files.
 
Back
Top