range object

This is a discussion on "range object" within the JavaScript Forum section. This forum, and the thread "range object are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 6th, 2004, 10:40
Junior Member
Join Date: Oct 2004
Location: USA
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to da_stimulator Send a message via AIM to da_stimulator Send a message via Yahoo to da_stimulator
range object

I'm trying to develop a script that will select elements within an html page, kind of like a select-all script, but I want it to be "select-some"

The code I have so far is below, however, looping through the array of divs, it will only select the latter in the array. Through research I've concluded that I may somehow be able to workaround this using properties that are available to set the start and end position of the text range, however, I have no clue whatsoever how to use these

Code: Select all
<html>
<head>
<script language="javascript">
function copySeperate(multipleID) {
multipleID = multipleID.split(",");
var i;
for(i in multipleID)
  copySel(multipleID[i]);
}
function copySel(tagID){
	refNode = document.getElementById(tagID);
	
	if (document.selection) {
		var range = document.body.createTextRange();
		range.moveToElementText(refNode);
		range.select();
		//range.execCommand("Copy");
	} else if (window.getSelection) {
		var range = document.createRange();
		range.selectNodeContents(refNode);
		var selection = window.getSelection();
		selection.removeAllRanges();
		selection.addRange(range);
	}
}
</script>
</head>
<body>
  <div id="d1">This is div 1, I want to select this</div>


  <div id="d2">This is div 2, I dont wanna select this</div>


  <div id="d3">This is div 3, I want to select this</div>


  
  <input type="button" value="1 and 3" onClick="copySeperate('d1,d3')" />
</body>
</html>

Closed Thread

Tags
range, object

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling Dropdown based on value range Matc JavaScript Forum 0 Jun 26th, 2007 11:02
Out of range error csun PHP Forum 1 May 6th, 2007 14:16
Setting a veiwing range for a AI character Throntel Flash & Multimedia Forum 7 Dec 17th, 2006 06:08
Updating using a range? BrokenImage Databases 2 Nov 18th, 2005 13:00


All times are GMT. The time now is 09:32.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43