Setting the value of an input in the parent window (the LP Editor) using JS on the page itself | Community
Skip to main content
Thorsten
New Participant
February 16, 2023
Solved

Setting the value of an input in the parent window (the LP Editor) using JS on the page itself

  • February 16, 2023
  • 1 reply
  • 4114 views

Hi everyone,

I am using a custom namespace in my (guided) landing page template. Is it somehow possible to leverage some of it in the landing page editor as well?

It seems like it's not even possible to do a 

 

 

var td = {};

 

 

Is the editor filtering this out?

My goal would be to auto-fill a string template variable with the landing page URL and adding some UTM tags, which will then be used as the OG URL when sharing the page, so it's rendered with the page already.

Kind regards,

Thorsten

 

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 SanfordWhiteman

Oh wait, you mean setting the value of an input in the parent window (the LP Editor) using JS on the page itself. Certainly possible — or used to be when I wrote something similar to hook up a color picker in the editor.

1 reply

SanfordWhiteman
New Participant
February 16, 2023

Are you asking if you can include a local <script> element in an editable content area using the HTML source editor? Not sure what this has to do with namespaces — do you mean namespaced HTML elements? Please provide more info here.

Thorsten
ThorstenAuthor
New Participant
February 17, 2023

Ok, maybe I shouldn't have gotten hung up on the word "namespace".

 

To clarify what I am trying to do:

  • I have a guided template, with a string-type variable (like that)
  • I have some JS code that will be part of the template that aims to set the value of this string variable when the user is in the landing page editor
  • I fail to even create a variable on the window object, like in my example above - as my intention was to put my function into that object, so just to have my custom code neat and tidy under window.td.fillThatVariable()
  • It looks like it doesn't let me create the JS variable at window.td and initialise with an empty object to start with
  • I currently try to set this variable within a <script> block in the <HEAD>, but some other test variable in <BODY> didn't work either for that matter, they just don't exist when I create a new LP in the editor and go to the browser console

 

Thorsten
ThorstenAuthor
New Participant
February 17, 2023

It's starting to dawn on me that I need to dig a level deeper into the window of the iFrame.