Different behavior when using window.location on IE ,FireFox and Chrome by passing URL string as a Token | Community
Skip to main content
February 25, 2014
Solved

Different behavior when using window.location on IE ,FireFox and Chrome by passing URL string as a Token

  • February 25, 2014
  • 6 replies
  • 9515 views
Hi,

I'm trying to create a landing page
 - that moves automatically to another URL in JavaScript code
 - the URL is passed as a TOKEN( I created a new custom field ,named it "Recommended URL" and trying to use as a token.
 
So I added a HTML component on the landing page and wrote Javascript code as below.

<script type="text/javascript" src="/js/public/jquery-latest.min.js"></script>
<script type="text/javascript">
  var $jQ = jQuery.noConflict();

  $jQ(document).ready(function(){

    window.location = "{{lead.Recommended Url:default=http://DEFAULT.co.jp}}";

  });
 
</script>

The results are as follows:

On Internet Explorer 11 
 ->It works well.
When "Recommended URL" filed is empty,it goes to default web page.
And When not empty,it goes to the web page that specified in "Redommended URL".

On FireFox 27.0.1 and Chrome 33.0 → It doesn't work. "404 Page Not Found" page is shown.

I wonder what  the cause of this different behavior between on IE and FireFox,Chrome is,
and how I can do what I wanted to do.

Could anyone help me with this?

Thanks,
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by
there could be many issues at play. what does your Javascript console (F12 or firebug) say? is there an error that we can look at?

also you may want to use window.location.assign() which is a common workaround for this issue

6 replies

February 25, 2014
Have you tried 

window.location.href =

It could be an issue with opening a new window? 
February 25, 2014
Hi Jeffrey,

Thank you for the prompt reply !

Following your advise, I have tried
 
 winow.locatio.href =

but it didn't work on FireFox ,Chrome and worked well on IE(the same as "window.location=").

Should I check  browser's option or something?
February 25, 2014
I found the article that was trying to do almost the same thing what  I wanted to do.

community.marketo.com/MarketoDiscussionDetail?id=90650000000PlSmAAK#

According to this article, all system tokens and lead tokens are encoded in Marketo.
-> so the URL is  ampersand encoded (like "&#104;&#116;&#116;&#112;&#58;......)

I did some change as witten in the article and it worked as I  expected.

But I think I shoud give it another thought from the viewpoint of avoiding script injection and so on.

Thanks,

Accepted solution
February 25, 2014
there could be many issues at play. what does your Javascript console (F12 or firebug) say? is there an error that we can look at?

also you may want to use window.location.assign() which is a common workaround for this issue
February 27, 2014
Hi Matt,

I'm sorry for the late reply.
There were no error on my Javascript cosole.

And,thank you for giving me a nice advise.
I tried it and it worked perfectly!!

I really appreciate it.
Thanks!
February 27, 2014
Glad it worked for you! 
Geko (the firefox javascript engine) has sadly become the new IE..where it does things.....differently then most browsers haha. so my suggestion is to always go to developer.mozilla.com and check out there javascript references because it has some of those quirks.