SOLVED

Re: Is there anyway to block custom javascript from running in the Marketo LP editor?

Go to solution
Justin_Morris
Level 2

Is there anyway to block custom javascript from running in the Marketo LP editor?

Hi,

We have a webinar landing page that allows for up to 5 presenters. Our developer wrote some custom code that behaves like this: If one of the image placeholders is removed from a presenter row, hide that row. This allows us to simply use the same template but with different numbers of presenters and add/remove them as needed. This was working fine until we upgraded to SSL. Now within the editor, when I remove one of the images, the javascript begins to load and the editor crashes. When I reload the page it just shows nothing in the presenter area. This was happening before when the javascript was coded directly in the footer. But I made it into a separate JS page and called to it in the footer and that solved the issue. But now it's seeming like SSL brought the issue back. Does anyone have any insights or advice on how this Javascript could still work? Or a way it could be disabled just in the Marketo editor. The code is below.

$(document).ready(function(){

  

  $(".profile-wrapper").each(function(){

 

  if ($(this).find('img').length) {

  // there is an image in this div, do anything here..

  } else

  {

  $(this).remove();

  }

 

});

  });

1 ACCEPTED SOLUTION

Accepted Solutions
Mark_Price
Level 7

Re: Is there anyway to block custom javascript from running in the Marketo LP editor?

Hi Justin,

If you have chrome inspector tools open while creating the error, does anything show under 'console' ?   interested to see if an error is showing.  Do you have a link to the live page ?

I've had a similar issue with pages that use redirects and either of these can work:

Setup a program token for  {{my.scriptNameBehavior}} and set the value to  on/off.  Your script can then

use the token as a variable and only run when 'activated' via program token

or

Setup the script so that it doesn't run if the current page url contains:  marketodesigner.com

Others might have some more ideas...  Hope it helps!

View solution in original post

4 REPLIES 4
Mark_Price
Level 7

Re: Is there anyway to block custom javascript from running in the Marketo LP editor?

Hi Justin,

If you have chrome inspector tools open while creating the error, does anything show under 'console' ?   interested to see if an error is showing.  Do you have a link to the live page ?

I've had a similar issue with pages that use redirects and either of these can work:

Setup a program token for  {{my.scriptNameBehavior}} and set the value to  on/off.  Your script can then

use the token as a variable and only run when 'activated' via program token

or

Setup the script so that it doesn't run if the current page url contains:  marketodesigner.com

Others might have some more ideas...  Hope it helps!

Justin_Morris
Level 2

Re: Is there anyway to block custom javascript from running in the Marketo LP editor?

I did use chrome inspector but nothing was showing up as an error under 'console.' However, setting up the script so that it doesn't run when the page contained that specific URL worked - amazing, thank you!

SanfordWhiteman
Level 10 - Community Moderator

Re: Is there anyway to block custom javascript from running in the Marketo LP editor?

I like Mark's 2nd approach of only running

if (!/.marketodesigner.com$/.test(document.location.hostname)) {

// special stuff

}

but also wonder if your <div class="profile-wrapper"> ends up completely empty when the <img> isn't there? If so, you can hide it using CSS alone, no JS necessary.

Justin_Morris
Level 2

Re: Is there anyway to block custom javascript from running in the Marketo LP editor?

Thank you for providing that code - it worked!