Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8184427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:29:51+00:00 2026-06-07T01:29:51+00:00

I am trying to get the selected area from an iFrame. There are a

  • 0

I am trying to get the selected area from an iFrame. There are a couple of similar post here but none works, so I decided to give it another try again.

function getIframeSelectionArea() {
var frm = frames['iFrameTextBody'].document;
var win = frm.contentWindow;
alert(win.getSelection().toString());
}

So what I am trying to implement is similar to what’s implemented in stackoverflow post textarea. Now I know they are using a variation of a 3rd party wysiwyg editor. I am trying to re-event the wheel purely for educational purposes.

My implementation is simple. I want to select a text and say by clicking bold have <b></b> tags appear on either side of the selected area. I know I an use execCommand(‘bold’, false, null) to do the same. As I said before this is a experiment.

The idea is, once the selected area is returned, call the following function:

    function addhtmlTag(str){
    var frm = frames['iFrameTextBody'].document;
    var frmbody = frm.getElementsByTagName('body')[0];
    var bold_tag = frm.createElement('b');
    bold_tag.textContent = str;
    frmbody.appendChild(bold_tag);
}

Any insight is greatly appreciated!

Cheers

Drjay

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:29:54+00:00Added an answer on June 7, 2026 at 1:29 am

    Do you mean something like:

    function getSelectionFrame() {
       var frame = document.getElementById(frameId);
       var frameWindow = frame.contentWindow;
       var frameDocument = frameWindow.document;
       if (frameDocument.getSelection) {
          return frameDocument.getSelection();
       } else {
          return frameDocument.selection.createRange().text;
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get the selected option from a dropdown and populate another
I am trying to get value of selected item from dropdown menu via val()
I am trying to get the value user selected from search prompt and pass
Hi am trying to get the value of p:selectOneMenu from jquery , but i
I am trying to get selected text of Iframe using Rangy using this function;
I am trying to get selected value of dropdownchoice in wicket framework , but
I'm trying to get the selected value from a drop down list via jQuery.
I am trying to get selected value in combobox but it returns as a
Trying to get the selected image from the photo chooser task into a image
I'm trying to understand how getListCellRendererComponent method works but I don't get it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.