S
S
synapse_people2016-10-01 12:15:47
JavaScript
synapse_people, 2016-10-01 12:15:47

How to pass JSON and call a function in page context?

There is a content script, it contains the following:

var script = document.createElement('script');
script.textContent = 'window.autofill_lead = ' + JSON.stringify(request.lead) + ';';
document.head.appendChild(script);

if you make a call in the context of the page (in the console or via proto javascript:...) it
console.log(window.autofill_lead)
returns undefined!
You need to somehow add an extension script to the page itself (embed a script with a function) and call it with data, while everything should happen in the context of the PAGE. Help me please!!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
romy4, 2016-10-01
@romy4

why can't you do :window.autofill_lead = JSON.parse(request.lead)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question