Is there anyway to block custom javascript from running in the Marketo LP editor? | Community
Skip to main content
Level 2
December 21, 2017
Solved

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

  • December 21, 2017
  • 2 replies
  • 3366 views

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();

  }

 

});

  });

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 Mark_Price

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!

2 replies

Mark_PriceAccepted solution
Level 6
December 21, 2017

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!

Level 2
December 22, 2017

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
December 22, 2017

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.

Level 2
December 22, 2017

Thank you for providing that code - it worked!