Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
Can I define "document" as a variable in Javascript?

In my application, I sometimes want to define "document" for use in querySelector as "tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow.document". Other times, I want "document" to have it's usual meaning.

Is there a way I can set "document" to be a variable? I've tried the following, none of which return an element:

Defining document:

document = tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow.document;
document.querySelector(myElement)  // Returns nothing

Defining a prefix:

prefix = tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow;
prefix.document.querySelector(myElement);  //Returns nothing

Defining a prefix as text:

prefix = "tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow;
    prefix.document.querySelector(myElement)";  //Returns nothing

Only tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow.document.querySelector(myElement) returns an element.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I found my own answer. I'll post it in case anyone else comes across this post.

First, find your TinyMCE Editor iframe

var iframe = document.querySelector("#myDiv .tox-editor-container .tox-edit-area iframe");

Then get its contents

var iframe_content = iframe.contentDocument;

Then you can perform your queries

var frame_li = iframe_content.querySelectorAll("#tinymce li");
about 4 years ago · Juan Pablo Isaza Report

0

Have you tried window.orig_document = window.document window.document = tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow.document window.document = window.document.orig_document

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!