Question

Qn for lil_puffball

Asked by: yuvarajr

Hi lil_puffball
You've answered my previous qn http://experts-exchange.com/Web/Web_Languages/JavaScript/Q_20951696.html. In that you told me that in case if i need to use frames, i can put all those buttons in the html of top frame and then i need to replace all document. with parent.bottomframe.document. . But the code does not work b'cos it could not set the x and y cursor position in the bottom frame. I am not allowed to modify the html in the bottom frame. Can you please help me to make the buttons work properly without modifying the html in bottom frame?..

Thanks in advance

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-05-18 at 15:08:19ID20993966
Tags

javascript

Topic

JavaScript

Participating Experts
1
Points
125
Comments
16

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Points for lil_puffball
    Regarding question at: http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20550173.html
  2. Free DHTML menu request - 125 points for lil_puffball
    Hi lil_puffball, Your answer corresponds exactly to my request. Thanks a lot.
  3. points for lil_puffball
    Here are your points for http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20593014.html Please post a comment to collect them
  4. Points for lil_puffball
    For: http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20612579.html Sorry about that. I didn't reload between looking at the Q and posting. Cd&

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: lil_puffballPosted on 2004-05-18 at 15:27:16ID: 11102957

Hi yuvarajr,

Why can you not modify the code in the bottom frame? If it is not on your server, you can't do anything to the page at all.

If it is on your server, then can you post the code for both frames here? It's a lot easier debugging with some code. ;)

 

by: yuvarajrPosted on 2004-05-18 at 18:50:52ID: 11103965

Hi lil_puffball,
The html file which i need to show on the bottom frame is on the server. So i can very well access the file. If modifying the file is the only way out, is there any way that we can modify the file just before showing it in the bottom frame and not save the actual file?.

Here is the sample code.

Code for frameset.html

<HTML>
      <frameset rows="20%,80%" frameborder="1" id="frameMain">
            <frame id="frameTop" src="Buttons.html" width="600">
            <frame id="frameBottom" src="Testing.htm" width="600">
      </frameset>
</HTML>

Code for top frame:(i'm pasting the entire solution which you gave before - i've replaced the document. with parent.frameBottom.document)

<html>
<style>button{width:200px;}</style>

<script>
var clr='yellow';
var offset=2,lineHgt;
var hiliText=new Array();
var hiliLoc=new Array();
var hiliDiv=new Array();
var bkmkText=new Array();
var bkmkLoc=new Array();
var bkmkDiv=new Array();
var x,y,cursorX=null,cursorY=null;

function initHiliBkmk(){
  var sel=parent.frameBottom.document.body.createTextRange(),loc;
  clearHili(false);
  sel.moveToElementText(parent.frameBottom.document.getElementById("content"));sel.collapse();
  var curSel;
  for(i=0;i<hiliLoc.length;i++){
    loc=hiliLoc[i].split("-");
    curSel=sel.duplicate();
    curSel.moveEnd("character",loc[1]);curSel.moveStart("character",loc[0]);
    if(curSel.text!=""){hili(curSel,false);}
  }
  for(i=0;i<bkmkLoc.length;i++){
    curSel=sel.duplicate();
    curSel.move("character",
bkmkLoc[i]);
    if(arguments.length>0){
      var img=parent.frameBottom.document.createElement("div");
      img.id="bookmark"+i;
      img.style.position="absolute";
img.style.top=cursorY;img.style.left=cursorX;
      img.innerHTML="<img src='bookmark.gif' title='"+bkmkText[i]+"' height=15 unselectable=on>";
      img.unselectable="on";
      img.onmousedown=function(){startDrag(this);}
      parent.frameBottom.document.body.appendChild(img);
    }
    bkmkDiv[i].style.left=curSel.boundingLeft-offset;
    bkmkDiv[i].style.top=curSel.boundingTop-offset;
  }
}
function hili(sel){
  if(sel.text==""){alert("Please select some text first!");return;}
  if(sel.boundingHeight>lineHgt){
    createHili(sel.boundingTop-offset,sel.offsetLeft-offset,sel.boundingWidth-sel.offsetLeft+sel.boundingLeft,lineHgt,clr);
    for(i=1;i<parseInt(sel.boundingHeight/lineHgt)-1;i++){
      createHili(sel.boundingTop-offset+lineHgt*i,sel.boundingLeft-offset,sel.boundingWidth,lineHgt,clr);
    }
    var newsel=sel.duplicate();
    while(sel.inRange(newsel)){
      newsel.moveStart("character");
    }newsel.moveStart("character",-1);
    createHili(newsel.boundingTop-offset,sel.boundingLeft-offset,newsel.boundingLeft-sel.boundingLeft,lineHgt,clr);
  }else{
    createHili(sel.boundingTop-offset,sel.boundingLeft-offset,sel.boundingWidth,sel.boundingHeight,clr);
  }
  if(arguments.length==1){storeHili(sel);}
}
function storeHili(sel){
  hiliText[hiliText.length]=sel.text;
  var tempSel=sel.duplicate(),tempSel2=sel.duplicate();
  tempSel.collapse();tempSel2.collapse(false);
  hiliLoc[hiliLoc.length]=getCursorPos(tempSel)+"-"+getCursorPos(tempSel2);
}
function createHili(t,l,w,h,clr){
  var div=parent.frameBottom.document.createElement("div");
  div.style.height=h;div.style.width=w;
  div.style.left=l;div.style.top=t;
  div.style.position="absolute";div.style.fontSize="0px";div.style.backgroundColor=clr;div.innerHTML="&nbsp";div.style.zIndex=-1;
  parent.frameBottom.document.body.appendChild(div);
  hiliDiv[hiliDiv.length]=div;
}
function clearHili(){
  for(i=0;i<hiliDiv.length;i++){
    hiliDiv[i].parentNode.removeChild(hiliDiv[i]);
  }
  if(arguments.length==0){hiliText.length=0;hiliLoc.length=0;hiliDiv.length=0;}
}
function clearBookmarks(){
  for(i=0;i<bkmkDiv.length;i++){
    bkmkDiv[i].parentNode.removeChild(bkmkDiv[i]);
  }
  bkmkText.length=0;bkmkLoc.length=0;bkmkDiv.length=0;
}
function insertBookmark(){
  if(!cursorX){alert("Please click somewhere first.");return;}
  var text=prompt("Enter the text:","Bookmark "+(bkmkDiv.length+1));
  if(!text){return;}
  var img=parent.frameBottom.document.createElement("div");
  img.id="bookmark"+bkmkDiv.length;
  img.style.position="absolute";
  img.style.top=cursorY;
  img.style.left=cursorX;
  img.innerHTML="<img src='bookmark.gif' title='"+text+"' height=15 unselectable=on>";
  img.unselectable="on";
  img.onmousedown=function(){startDrag(this);}
  parent.frameBottom.document.body.appendChild(img);
  bkmkDiv[bkmkDiv.length]=img;
  bkmkText[bkmkText.length]=text;
  snapToText(img,bkmkLoc.length);
}
var offL,offT,drag=false,obj;
function startDrag(srcEl){obj=srcEl;offL=x-getLeft(obj);offT=y-getTop(obj);drag=true;}
function dragObj(){obj.style.left=x-offL;obj.style.top=y-offT;}
function getLeft(obj){return parseInt(obj.style.left);}
function getTop(obj){return parseInt(obj.style.top);}
function init(){
  var div=parent.frameBottom.document.createElement("div");
  div.innerHTML="1";
  parent.frameBottom.document.body.appendChild(div);
  lineHgt=div.offsetHeight;
  div.parentNode.removeChild(div);
}
function getCursorPos(sel){
  var pos=parent.frameBottom.document.body.createTextRange();
  pos.moveToElementText(parent.frameBottom.document.getElementById("content"));
  pos.collapse();var cnt=0;
  while(!sel.inRange(pos)){
pos.move("character");cnt++;}
  return cnt;
}
function snapToText(img,n){
  var start=parent.frameBottom.document.body.createTextRange();
  start.moveToElementText(parent.frameBottom.document.getElementById("content"));
  var end=start.duplicate();start.collapse();end.collapse(false);var newsel=start.duplicate();
  var cnt=0,pos=0,l=parseInt(img.style.left),t=parseInt(img.style.top);
  var dif=Math.abs(l-start.boundingLeft)+Math.abs(t-start.boundingTop),thisDif;
  while(!end.inRange(start)){
    start.move("character");cnt++;
    thisDif=Math.abs(l-start.boundingLeft)+Math.abs(t-start.boundingTop);
    if(thisDif<dif){pos=cnt;dif=thisDif;}
  }
  newsel.move("character",
pos);
  img.style.left=newsel.boundingLeft-offset;
  img.style.top=newsel.boundingTop-offset;
  bkmkLoc[n]=getCursorPos(newsel);
}
</script>

<body onload="init();"onresize="initHiliBkmk();" onmousemove="x=event.x;y=event.y;if(drag){dragObj();}" onmouseup="if(drag){drag=false;snapToText(obj,obj.id.charAt(obj.id.length-1));}">

<button onclick="hili(parent.frameBottom.document.selection.createRange());">Hilight Text</button>
<button onclick="clearHili();">Clear All Highlights</button>
<button onclick="alert(hiliText.join('\n---------------\n'));">Get Highlight Text</button>
<button onclick="alert(hiliLoc.join('\n---------------\n'));">Get Highlight Positions</button>
<br>
<button onclick="insertBookmark();">Insert Bookmark</button>
<button onclick="clearBookmarks();">Clear All Bookmarks</button>
<button onclick="alert(bkmkText.join('\n---------------\n'));">Get Bookmark Text</button>
<button onclick="alert(bkmkLoc.join('\n---------------\n'));">Get Bookmark Positions</button>

<div id=content onclick="cursorX=x;cursorY=y;">
Here is some text... Here is some text... Here is some text... Here is some text... Here is some text...
Here is some text... Here is some text... Here is some text... Here is some text... Here is some text...
Here is some text... Here is some text... Here is some text... Here is some text... Here is some text...
Here is some text... Here is some text... Here is some text... Here is some text... Here is some text...
Here is some text... Here is some text... Here is some text... Here is some text... Here is some text...
Here is some text... Here is some text... Here is some text... Here is some text... Here is some text...
</div>
</body>
</html>

HTML for bottom frame:

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 9">
<meta name=Originator content="Microsoft Word 9">
<link rel=File-List href="./testing_files/filelist.xml">
<title>testing</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>yrajaram</o:Author>
  <o:LastAuthor>yrajaram</o:LastAuthor>
  <o:Revision>2</o:Revision>
  <o:TotalTime>0</o:TotalTime>
  <o:Created>2004-05-19T01:09:00Z</o:Created>
  <o:LastSaved>2004-05-19T01:09:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Company>FileNET Corporation</o:Company>
  <o:Lines>1</o:Lines>
  <o:Paragraphs>1</o:Paragraphs>
  <o:Version>9.3821</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:AttachedTemplate
   HRef="C:\Documents and Settings\yrajaram\Application Data\Microsoft\Templates\Normal.dot"></w:AttachedTemplate>
 </w:WordDocument>
</xml><![endif]-->
<style>
<!--
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
      {mso-style-parent:"";
      margin:0in;
      margin-bottom:.0001pt;
      mso-pagination:widow-orphan;
      font-size:12.0pt;
      font-family:"Times New Roman";
      mso-fareast-font-family:"Times New Roman";}
@page Section1
      {size:8.5in 11.0in;
      margin:1.0in 1.25in 1.0in 1.25in;
      mso-header-margin:.5in;
      mso-footer-margin:.5in;
      mso-paper-source:0;}
div.Section1
      {page:Section1;}
-->
</style>
</head>

<body lang=EN-US style='tab-interval:.5in'>

<div class=Section1>

<p class=MsoNormal>testing</p>

</div>

</body>

</html>

Thanks.

 

by: yuvarajrPosted on 2004-05-19 at 10:56:53ID: 11110388

Hi lil_puffball,
i've tried using the include statement to include the bottomframe html inside the main asp page where i've this javascript code. like <!-- #include file='testing.html' --> and it works. This allows me to add bookmark without modifying the html.
Thanks.

 

by: lil_puffballPosted on 2004-05-19 at 12:53:21ID: 11111463

So you solved it yourself then? If so, you can post a question in Community Support to get your points refunded.

 

by: yuvarajrPosted on 2004-05-19 at 13:43:16ID: 11111901

Hi lil_puffball,
Sorry to bug you again..Can you please tell me your idea of doing this?.

Thanks again.

 

by: yuvarajrPosted on 2004-05-19 at 13:53:57ID: 11111972

Actually i've used ASP include syntax in that sample.. It takes some time to add bookmark after clicking on Add Bookmark button. I am not sure why. Can you please tell me is there any other way to do that using frames?

 

by: lil_puffballPosted on 2004-05-19 at 14:09:33ID: 11112106

Sure. :) I'm rather busy right now but I will work on it later...

 

by: lil_puffballPosted on 2004-06-16 at 10:45:19ID: 11326950

I have no objections, although yuvarajr if you still need a solution I will probably be able to provide one in a week or so. This is actually the first time I've checked on EE in 3 weeks, since I've been preoccupied with my year-end projects and exams. I will be completely free by next wednesday though. My apologies for not replying sooner.

 

by: yuvarajrPosted on 2004-06-16 at 15:07:07ID: 11329432

Thx lil_puffball..i'd rather wait to have your solution than closing it now.

Moderator,
Can you pls not close this question?. I want this to be open.
Thanks.

 

by: lil_puffballPosted on 2004-07-04 at 08:42:23ID: 11468100

yuvarajr,

Sorry about the delay once again, I am now working on it. :)

 

by: lil_puffballPosted on 2004-07-04 at 08:56:56ID: 11468168

Ok, I just looked at the code, and I've found some problems that I'll fix. First off, though--I currently have the text placed in a div (with id="content"). So I'm not sure if you will keep that div in the bottom frame. Seems to me like everything in the bottom frame will be text that can be highlighted, is that right? Please let me know if I misunderstood, meanwhile I'll just code assuming everything in the bottom frame will be text.

 

by: lil_puffballPosted on 2004-07-04 at 09:53:32ID: 11468373

Alright, try this code for the top frame:

===============================================
===============================================

<html>
<style>button{width:200px;}</style>

<script>
var clr='yellow';
var offset=2,lineHgt;
var hiliText=new Array();
var hiliLoc=new Array();
var hiliDiv=new Array();
var bkmkText=new Array();
var bkmkLoc=new Array();
var bkmkDiv=new Array();
var x,y,cursorX=null,cursorY=null;

function initHiliBkmk(){
  var sel=parent.frameBottom.document.body.createTextRange(),loc;
  clearHili(false);
  sel.collapse();
  var curSel;
  for(i=0;i<hiliLoc.length;i++){
    loc=hiliLoc[i].split("-");
    curSel=sel.duplicate();
    curSel.moveEnd("character",loc[1]);curSel.moveStart("character",loc[0]);
    if(curSel.text!=""){hili(curSel,false);}
  }
  for(i=0;i<bkmkLoc.length;i++){
    curSel=sel.duplicate();
    curSel.move("character",
bkmkLoc[i]);
    if(arguments.length>0){
      var img=parent.frameBottom.document.createElement("div");
      img.id="bookmark"+i;
      img.style.position="absolute";
img.style.top=cursorY;img.style.left=cursorX;
      img.innerHTML="<img src='bookmark.gif' title='"+bkmkText[i]+"' height=15 unselectable=on>";
      img.unselectable="on";
      img.onmousedown=function(){startDrag(this);}
      parent.frameBottom.document.body.appendChild(img);
    }
    bkmkDiv[i].style.left=curSel.boundingLeft-offset;
    bkmkDiv[i].style.top=curSel.boundingTop-offset;
  }
}
function hili(sel){
  if(sel.text==""){alert("Please select some text first!");return;}
  if(sel.boundingHeight>lineHgt){
    createHili(sel.boundingTop-offset,sel.offsetLeft-offset,sel.boundingWidth-sel.offsetLeft+sel.boundingLeft,lineHgt,clr);
    for(i=1;i<parseInt(sel.boundingHeight/lineHgt)-1;i++){
      createHili(sel.boundingTop-offset+lineHgt*i,sel.boundingLeft-offset,sel.boundingWidth,lineHgt,clr);
    }
    var newsel=sel.duplicate();
    while(sel.inRange(newsel)){
      newsel.moveStart("character");
    }newsel.moveStart("character",-1);
    createHili(newsel.boundingTop-offset,sel.boundingLeft-offset,newsel.boundingLeft-sel.boundingLeft,lineHgt,clr);
  }else{
    createHili(sel.boundingTop-offset,sel.boundingLeft-offset,sel.boundingWidth,sel.boundingHeight,clr);
  }
  if(arguments.length==1){storeHili(sel);}
}
function storeHili(sel){
  hiliText[hiliText.length]=sel.text;
  var tempSel=sel.duplicate(),tempSel2=sel.duplicate();
  tempSel.collapse();tempSel2.collapse(false);
  hiliLoc[hiliLoc.length]=getCursorPos(tempSel)+"-"+getCursorPos(tempSel2);
}
function createHili(t,l,w,h,clr){
  var div=parent.frameBottom.document.createElement("div");
  div.style.height=h;div.style.width=w;
  div.style.left=l;div.style.top=t;
  div.style.position="absolute";div.style.fontSize="0px";div.style.backgroundColor=clr;div.innerHTML="&nbsp";div.style.zIndex=-1;
  parent.frameBottom.document.body.appendChild(div);
  hiliDiv[hiliDiv.length]=div;
}
function clearHili(){
  for(i=0;i<hiliDiv.length;i++){
    hiliDiv[i].parentNode.removeChild(hiliDiv[i]);
  }
  if(arguments.length==0){hiliText.length=0;hiliLoc.length=0;hiliDiv.length=0;}
}
function clearBookmarks(){
  for(i=0;i<bkmkDiv.length;i++){
    bkmkDiv[i].parentNode.removeChild(bkmkDiv[i]);
  }
  bkmkText.length=0;bkmkLoc.length=0;bkmkDiv.length=0;
}
function insertBookmark(){
  if(!cursorX){alert("Please click somewhere first.");return;}
  var text=prompt("Enter the text:","Bookmark "+(bkmkDiv.length+1));
  if(!text){return;}
  var img=parent.frameBottom.document.createElement("div");
  img.id="bookmark"+bkmkDiv.length;
  img.style.position="absolute";
  img.style.top=cursorY;
  img.style.left=cursorX;
  img.innerHTML="<img src='bookmark.gif' title='"+text+"' height=15 unselectable=on>";
  img.unselectable="on";
  img.onmousedown=function(){startDrag(this);}
  parent.frameBottom.document.body.appendChild(img);
  bkmkDiv[bkmkDiv.length]=img;
  bkmkText[bkmkText.length]=text;
  snapToText(img,bkmkLoc.length);
}
var offL,offT,drag=false,obj;
function startDrag(srcEl){obj=srcEl;offL=x-getLeft(obj);offT=y-getTop(obj);drag=true;}
function dragObj(){obj.style.left=x-offL;obj.style.top=y-offT;}
function getLeft(obj){return parseInt(obj.style.left);}
function getTop(obj){return parseInt(obj.style.top);}
function init(){
  var div=parent.frameBottom.document.createElement("div");
  div.innerHTML="1";
  parent.frameBottom.document.body.appendChild(div);
  lineHgt=div.offsetHeight;
  div.parentNode.removeChild(div);

  var fr=parent.frameBottom.document;
  fr.onmousemove=new Function("x=parent.frameBottom.event.x;y=parent.frameBottom.event.y;if(drag){dragObj();}");
  fr.onmouseup=new Function("if(drag){drag=false;snapToText(obj,obj.id.charAt(obj.id.length-1));}");
  fr.onclick=new Function("cursorX=x;cursorY=y;");
}
function getCursorPos(sel){
  var pos=parent.frameBottom.document.body.createTextRange();
  pos.collapse();var cnt=0;
  while(!sel.inRange(pos)){
    pos.move("character");cnt++;}
  return cnt;
}
function snapToText(img,n){
  var start=parent.frameBottom.document.body.createTextRange();
  var end=start.duplicate();start.collapse();end.collapse(false);var newsel=start.duplicate();
  var cnt=0,pos=0,l=parseInt(img.style.left),t=parseInt(img.style.top);
  var dif=Math.abs(l-start.boundingLeft)+Math.abs(t-start.boundingTop),thisDif;
  while(!end.inRange(start)){
    start.move("character");cnt++;
    thisDif=Math.abs(l-start.boundingLeft)+Math.abs(t-start.boundingTop);
    if(thisDif<dif){pos=cnt;dif=thisDif;}
  }
  newsel.move("character",pos);
  img.style.left=newsel.boundingLeft-offset;
  img.style.top=newsel.boundingTop-offset;
  bkmkLoc[n]=getCursorPos(newsel);
}
</script>

<body onload="init();" onresize="initHiliBkmk();">

<button onclick="hili(parent.frameBottom.document.selection.createRange());">Hilight Text</button>
<button onclick="clearHili();">Clear All Highlights</button>
<button onclick="alert(hiliText.join('\n---------------\n'));">Get Highlight Text</button>
<button onclick="alert(hiliLoc.join('\n---------------\n'));">Get Highlight Positions</button>
<br>
<button onclick="insertBookmark();">Insert Bookmark</button>
<button onclick="clearBookmarks();">Clear All Bookmarks</button>
<button onclick="alert(bkmkText.join('\n---------------\n'));">Get Bookmark Text</button>
<button onclick="alert(bkmkLoc.join('\n---------------\n'));">Get Bookmark Positions</button>

</body>
</html>

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...