Amrendra Pratap Singh
Amrendra Pratap Singh

Reputation: 661

How to get content of particular column of html page after split using css-rule(-webkit-column-width:)

i splited html page in multiple columns using css rule

var mySheet = document.styleSheets[0];
function addCSSRule(selector, newRule) 
{
   if (mySheet.addRule) {
       mySheet.addRule(selector, newRule);// For Internet Explorer                              
   } else {
       ruleIndex = mySheet.cssRules.length;
       mySheet.insertRule(selector + '{' + newRule + ';}', ruleIndex)//for firefox..
   }
}

addCSSRule('html', 'padding: 0px; height: 460px; -webkit-column-gap: 0px; -webkit-column- width: 320px;');

How do I get content from particular column. Please help me.

Upvotes: 3

Views: 528

Answers (2)

Cuong Ta
Cuong Ta

Reputation: 1181

I can get the content after one hour to find and deploy . I hope my sharing will help someone.
Pls check in: jsfiddle.net/cuongtakien/7YMSL/1/

You can change the position of start and end point and calculate the height of each column . Finally,you change the my hard fixed in code and get content.
Thank mattsven to share about createRange in javascript. Have a nice code!

Upvotes: 1

Naman Goel
Naman Goel

Reputation: 1612

I'm pretty sure there is no simple way to do this. Your best bet is to find the length of the text and get the 1st half (or third, or fourth as the case may be) of the content. It won't be accurate, but it will be close.

The other way could be to select the content starting at the top, and figure out the end of a column by the position of the caret. (I'm just riffing here. Not sure if this actually works)

Upvotes: 1

Related Questions