I am trying to deploy my bookmarklet in public, but I am not sure what is the best way to do it. Suppose I have,
javascript:(function(){console.log("hello");}())
And I make it draggable to the bookmarklet by enclosing it within a href tag. The trouble is that HTML special characters are encoded like %07d for the above snippet. What's the conventional way to solve this problem?
Thank you!
It should work fine, till it is in the following format.
Bookmarklet
Note: I changed console.log() to alert() to make the result view able immediately.
Live Demo: http://jsfiddle.net/qyL4L/
Related
Does anyone have an example on how to use HTML5 code tag in order to display HTML code?
I tried to do that but it failed.
Afterwards, I tried to use highlight.js but still no luck.
Any suggestions?
Demo
The HTML code tag has nothing to do with beautifying. It simply indicates its content as computer code, and by default it causes it to be rendered in a monospace font. That’s all.
To get help with beautification, I suggest that you open a new question and post your best effort so far (not links to general resources but to code that you actually tried) and explain what you wish to achieve.
You would need to replace < tag with < and > with >. Only by escaping these characters can you see the html code
I created the below JavaScript Code Template in Netbeans 7.1.1
This is to generate code automatically in the editor, instead of typing it.
do_this('${selection}${cursor}',13)
which will result in the below code, with the cursor between quotes
do_this('',13)
The template automatically places the text I have highlighted, between quotes.
Now, the problem: I would like to replace any spaces within the selected/highlighted piece of code, with underscores. I think this may be possible with Regular Expressions (regex), however I am not sure how to go about it.
Thanks
Not sure about the Netbeans specific stuff, but once you have the selection you could do something like this:
selection = selection.split(" ").join("_");
This is not possible in NetBeans Code Templates, as they do not have any functions to manipulate the data in variables. If I have a work around for it, I will post it here.
Thanks.
I've made a simple bookmarklet, to aid with the reading of Daring Fireball.
http://saltcod.github.com/Snowball/
My issue is that the Drag Me Up, Scottie! link doesn't work when you drag it up. If you manually create the bookmark with the same code (https://raw.github.com/saltcod/Snowball/master/snowball.js) it will work, but it won't work if you try and drag it up.
The link is breaking the block of Javascript somehow. Anyone got any ideas as to what I might do with it?
You messed up the quotation marks; your page is NOT valid HTML.
Inside a link, you cannot use ", but either use ' or encode the quotation marks.
Did you not notice that your javascript link was truncated at the first "?
I have been looking around for a HTML formatter to incorporate with a project I am doing. I need it to be written in Javascript since I want the formatting done on the client side.
The problem is, the few that I have tried don't work very well... For example:
http://www.davidpirek.com/blog/html-beautifier-jquery-plugin : Has a problem with one of the For loops (in the cleanAsync function). Chrome says "unexpected token ILLEGAL"
JS Beautifier on GitHub : When I have links in the HTML it will put a newline character after it. The problem is, I have a period directly after the link in some cases and it will add a space between the link text and the period in the sentence. I tried poking around to fix it but I could not.
Are there any others, or does anyone have recommendations to fix the above two?
EDIT:
This is for editing code, so I just need something to tab in the lines, etc. The code output will go in a textarea.
A few to look at, all have working demos:
http://alexgorbatchev.com/SyntaxHighlighter/
http://shjs.sourceforge.net/
http://jush.sourceforge.net/
http://dojotoolkit.org/reference-guide/dojox/highlight.html
use https://github.com/beautify-web/js-beautify and pass your code to html_beautify() method.
I have two applications where users can submit HTML pages. I would like to make sure that no scripts are included in the HTML.
Normally you would escape content to get rid of scripts, but as this is HTML I can't do that. Anyone with good suggestions on how to do that? The applications are written in both C# and Java
OWASP has a project to scrub html and css
The first thing I'd do is see if there is a <script> tag in the HTML. That solves the first issue, then you have to make sure there are no inline onmouseover/onclick etc. events. You could maybe use a DOM Parser to go over all elements and remove all attributes that start with 'on'.
I have little to no experience in both C# as Java, so am unaware of any "easier" solutions that area already available. But maybe someone else here has a better idea for that.