admin管理员组文章数量:1399188
So I have made a web page of HTML, Inline CSS and JS. Since this page will be produced through JS function
opened.document.write();
I would like to put all the web page code into one line that can be taken in one of the previously mention function instead of repeating the same function for every new line. I can't affors doing this manually,because the page contains too many lines of code.
Is there a fast and clean way to do this?
Notice: I used SOME PROGRAM to replace all " with \" by one click, so I hope there is away to replace all the(Enter)s with (Backspace) or something like that.
Elaboration
I want to produce the whole page when the user click on a button which will call a JS function which will produce a new page and write it using the previously mentioned function.
So I have made a web page of HTML, Inline CSS and JS. Since this page will be produced through JS function
opened.document.write();
I would like to put all the web page code into one line that can be taken in one of the previously mention function instead of repeating the same function for every new line. I can't affors doing this manually,because the page contains too many lines of code.
Is there a fast and clean way to do this?
Notice: I used SOME PROGRAM to replace all " with \" by one click, so I hope there is away to replace all the(Enter)s with (Backspace) or something like that.
Elaboration
I want to produce the whole page when the user click on a button which will call a JS function which will produce a new page and write it using the previously mentioned function.
Share Improve this question edited Jan 10, 2010 at 10:36 M. A. Kishawy asked Jan 10, 2010 at 10:15 M. A. KishawyM. A. Kishawy 5,09914 gold badges49 silver badges73 bronze badges 8- 7 You used MS Word to edit code? – Ben James Commented Jan 10, 2010 at 10:18
- Whitespace is mostly ignored when rendering html, so what's your reason to for this? – Jimmy Shelter Commented Jan 10, 2010 at 10:18
- 2 I suggest notepad++ instead of word. Word is NOT for coding Mak.. – johnnyArt Commented Jan 10, 2010 at 10:27
- 1 From MS Word you should leap right into vim or emacs. Either you'll turn out really good, or go batshit insane---I give it 50/50. – Roger Pate Commented Jan 10, 2010 at 10:33
- MAK: Based on your elaboration, why are you even using word then? You're hard-coding the HTML you want it to produce? Well, then, as advised, use a proper text editor to get it in the correct format. But if you want to write out a segment of the already-existing page again, note you can get that with the '.innerHTML' property, if it interests you. – Noon Silk Commented Jan 10, 2010 at 10:34
3 Answers
Reset to default 6Hmm, well the answer is "Yes", but it's slightly disturbing what you are doing.
I don't know if you can replace special characters in Word, but in most text editors (Textpad, Notepad++) you can replace via a 'regex' so you can write "\r\n" to replace all instances of newlines with whatever you wish.
I must say, though, that I wonder why you wish to write out the document like that. Can you elaborate?
You could use an online text editor with regex, paste your code in and fix up some regex to replace \r and \n with a whitespace or no spaces. I don't know regex so you'll have to do it or ask for it yourself.
Changing your HTML pages to be generated by Javascript is a Very Bad Idea. You're making your entire website virtually invisible to Search Engines, users with javascript off, and those using screen readers, and for what benefit? Saving a couple of hundred bytes? Set up your webserver with gzip pression and proper cache control and leave the source as is.
本文标签: cssHow Can I minimize the HTML code by making it one line of codeStack Overflow
版权声明:本文标题:css - How Can I minimize the HTML code by making it one line of code? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744160581a2593317.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论