2

I need to use Bookmarklet to change the settings on some sites in its context. I have necessary var, but I dunno with help of which command to change selecting execution context.

Example

Which commands do use to change necessary var?

I checked:

  1. Select frame context with JavaScript
  2. Debugging iframes with Chrome developer tools
  3. what is the jQuery / JavaScript context of a frame within an iframe?
  4. Is there a way to change context to iframe in JavaScript console?

But this not help me

1 Answer 1

3

hi if you want to select element with id test2 you can use document.getElementById('test2') need to wrap test2 with quotes

and if element with id test2 is inside iframe you need to select iframe first and cal contentDocument

var iframe = document.getElementById('iframe-id');
iframe.contentDocument.getElementById('test2');

or if you are testing with chrome devtools you can change context and use document.getElementById('test2') as normal

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. But sadly I can't find iframe-id, most likely I misunderstand what I need to do, I'm sorry Screenshot, also
This migth no longer work due to cross-origin restrictions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.