SOLVED

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

Go to solution
Anonymous
Not applicable

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

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,
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

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

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

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

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

Have you tried 

window.location.href =

It could be an issue with opening a new window? 
Anonymous
Not applicable

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

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?
Anonymous
Not applicable

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

I found the article that was trying to do almost the same thing what  I wanted to do.

https://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,

Anonymous
Not applicable

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

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
Anonymous
Not applicable

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

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!
Anonymous
Not applicable

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

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.