SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Tricky word count

    Hey all,

    Would it be possible to have a webpage with normal HTML, but make it so the user can highlight some text, click a button and make it perform a word count on the selected text and disply the number of words in an alert()?

    Thanks

  2. #2
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can't think of a way off the top of my head, but obviously the hard part is getting the browser to recognise what text is highlighted.

    Could you not read the text from the clipboard assuming that the user not only highlights, but also copies the on-screen text, or is this something which is only possible in I.E.?

    More reading.


    Andy
    From the English nation to a US location.

  3. #3
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Search this thread for "mozilla" and there's something which claims to make copy-to-clipboard work for Mozilla.



    Andy
    From the English nation to a US location.

  4. #4
    Under Construction Poop_Shoot's Avatar
    Join Date
    Jul 2003
    Location
    Sacramento, CA
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was working on somthing like that I dont know how much it will help you but here!

    Code:
    <html>
    	<head>
    		<script language="Javascript">
    function searchDoc(what,mend){
     var found=false;
     var hm=0;
    <html>
    	<head>
    		<script language="Javascript">
    function searchDoc(what,mend){
     var found=false;
     var hm=0;
     var e=document.getElementById("searchArea").getElementsByTagName("*");
     var el=e.length;
      document.getElementById("output").innerHTML="";
     	for(var i=0;i<el;i++){
    		var str=e[i].innerHTML.toLowerCase();
    		var strSpl=str.split(" ");
    	  	for(var k=0;k<strSpl.length;k++){
    	  	if(strSpl[k]==what.toLowerCase()){
    		var cm=confirm("Do you want to replace Text!");
    		hm++;
    		found=true;
    		document.getElementById("output").innerHTML=" "+what+" was found "+hm+" times";	
      strSpl[k]=(cm)?'<span style="background-color:yellow;">'+mend+'</span>':'<span style="background-color:yellow;">'+strSpl[k]+'</span>';
    	e[i].innerHTML=strSpl.join(" ");
    		}
    	    }
            }
       if(!found){
        alert("Not Found On Page!");
        }  
    }
    
    		</script>
    		<style></style>
    	</head>
    	<body>
    		<form>
    			Find<input type="text" name="search" onkeypress="if(window.event.keyCode==13)sub.click();"> 
    			Replace<input type="text" name="edit" onkeypress="if(window.event.keyCode==13)sub.click();"> 
    			<input type="button" value="search" name="sub" onclick="searchDoc(this.form.search.value,this.form.edit.value);"
    			 onkeypress="if(window.event.keyCode==13)this.click();">
    		</form>
    		Results:
    		<span id="output"></span>
    		<hr>
    		<div id="searchArea">
    			<p>
    				on that week's sabbath-gasbag shows (as calvin trillin calls them), someone is 
    				certain to furrow his brow and declaim that thursday's blackout confirms, to a 
    				newly heightened degree, the american electrical grid's vulnerability to 
    				terrorism. not that that necessarily was a terrorist attack, the expert will 
    				concede (though with a cocked eyebrow, to suggest that, then again, maybe it 
    				was), but what if it had been? look, he will say, at how much damage the 
    				terrorists can cause. certainly the blackout dramatizes the fragility of our 
    				overloaded, archaic, unevenly managed electrical-transmission system. but it 
    				also reveals the system's—and society's—resilience. we have had, in one swoop, 
    				the largest blackout in u.s. history, wiping out electrical power for some 50 
    				million people, including much of the northeast corridor and the core of the 
    				nation's financial network. and yet, less than 24 hours later, most (though by 
    				no means all) of the power has been restored. financial markets were scantly 
    				affected, if at all. in new york city, just one person died (of a heart attack, 
    				after walking down many flights of stairs in a midtown skyscraper); the police 
    				recorded just three cases of looting, all minor; by thursday evening, planes 
    				were flying in to the area's airports. police, firefighters, and 
    				emergency-management crews worked with few disruptions. (some statistics: 
    				police responded to 80,000 911 calls, more than twice the normal number; 
    				firefighters fought 60 fires and made more than 800 elevator rescues; ems crews 
    				responded to 5,000 calls, 600 more than the previous record-high.) government 
    				officials—on city, state, and federal levels—communicated with one another, 
    				with almost no hitch, thanks in part to procedures put in place after the sept. 
    				11 terrorist attack. the point is: as big a deal as that blackout was (and, to 
    				some degree, still is), the streets did not erupt in panic; society remained 
    				fairly orderly; the wheels of government and finance turned. if that had been a 
    				terrorist attack, or if terrorists dream of inflicting such damage as this, one 
    				thing can be said: it did not unleash terror. major inconvenience, yes; terror, 
    				not remotely. that said, could a terrorist have caused that blackout or cause 
    				one like it in the future? doubtful. as of late friday afternoon, the 
    				executives and engineers who run the electrical network still don't know 
    				precisely where or how the trouble began. if they don't know how to find the 
    				precise vulnerability that caused such widespread damage, would anyone in 
    				al-qaida know? last summer, the naval war college commissioned gartner, a 
    				connecticut-based information-technology research group, to spin scenarios for 
    				a "digital pearl harbor"—a systematic attack on the nation's critical 
    				infrastructure networks: finance, transportation, telecommunications, the 
    				internet, and energy. the group dealing with the electrical network envisioned 
    				a two-pronged attack: first, the physical destruction of key transmission 
    				bottlenecks, followed by sabotage through the internet of the digital systems 
    				that allow supervisors to switch transmission flows on and off, and thus 
    				blocking them from restarting the power after the attack. regardless of whether 
    				such an attack is feasible, that certainly is not what happened thursday. no 
    				physical damage was done (or at least none was reported), and the digital 
    				systems that restart the flow of power are working fine. in other words, the 
    				blackout reveals nothing, one way or the other, about the network's 
    				vulnerability to terrorism. however, it is worth noting that invading key nodes 
    				of the electrical network, whether by hacking or whacking, is very difficult 
    				and getting harder. (for an elaboration of that point, click here.) according 
    				to a spokesman for the north american electric reliability center, hackers try 
    				to intrude on some aspect of the grid's computer network on a daily 
    				basis—never, so far, with any success. it's also worth noting that the digital 
    				networks are not connected nearly as widely as the transmission networks; even 
    				if someone managed to muck up one digital center, it would have limited effect. 
    				none of that is to warrant complacency, either about the electrical grid's 
    				ability to supply enough continuous power or about its security from terrorists 
    				and pranksters. just last tuesday, nerc issued a new protocol for enhancing 
    				cyber-security standards, and when it comes to such matters, there's no such 
    				thing as excessive caution. however, if we are vulnerable, the blackout 
    				probably tells us nothing new about why or how; if anything, it offers 
    				reassurance that society is more durable than many scenarios about terrorism 
    				suppose.
    			</p>
    		</div>
    	</body>
    </html>
    Last edited by Poop_Shoot; Aug 19, 2003 at 10:05.

  5. #5
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    It only needs to support IE, this isn't for a production website or anything, just to be run on an Intranet. All the users will be running IE6.01.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •