Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

JQuery/Javascript - Search DOM for text and insert HTML -


how search dom string in document's text (say, "cheese") insert html after string (say, "< b >is fantastic< /b >").

i have tried following:

for (var tag in document.innerhtml) {     if (tag.matches(/cheese/) != undefined) {         document.innerhtml.append(<b>is fantastic</b>     } } 

(the above more of illustration of have tried, not actual code. expect syntax horribly wrong please excuse errors, not problem).

cheers,

pete

there native methods finding text inside document:

msie:textrange.findtext()
others: window.find()

manipulate given textrange if found.
methods should provide more performance traversing of whole document.

example:

<html> <head>    <script>   function fx(a,b)   {     if(window.find)     {       while(window.find(a))       {         var node=document.createelement('b');             node.appendchild(document.createtextnode(b));         var rng=window.getselection().getrangeat(0);             rng.collapse(false);             rng.insertnode(node);       }     }     else if(document.body.createtextrange)     {       var rng=document.body.createtextrange();       while(rng.findtext(a))       {         rng.collapse(false);         rng.pastehtml('<b>'+b+'</b>');       }     }   }   </script> </head> <body onload="fx('cheese','is wonderful')"> <p>i've made wonderful cheesecake <i>cheese</i> <u>chees</u>e-factory!</p> </body> </html> 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -