Escaping Bookmarklet Code
Nov 13, 2006
When publishing bookmarklets, we put the bookmarklet code in anchor tag
like this:
<a href="javascript: alert('test');"name </a>
Some characters of the code need to be escaped. For example, double
quotes need to be escaped as %22 like in this example:
<a href="javascript: var doubleQuote = '%22' alert(doubleQuote);">
name </a>
Question: Is double quotes the only thing that need to be escaped?
I have seen examples of escaping spaces as %20, but it seems
unnecessary in most browsers i have used.
View 1 Replies
ADVERTISEMENT
Jul 24, 2006
I would like to create an image "slideshow" for which I am using the following loop:
<script type="text/javascript">
intImage = 22;
function swapImage() {
if (intImage >= 22) {
intImage=1; }
else {
intImage++;
document.getElementById("IMG1").src = "images/P"+intImage+".jpg";
} }
intImage = 1;
function swapImageback() {
if (intImage <= 1) {
intImage=22; }
else {
intImage--;
document.getElementById("IMG1").src = "images/P"+intImage+".jpg";
} }
</script>
The problem with the loop is that it's infinite, which I understand is generally not a very clever solution. In this particular case I would like to escape the loop with P20 and then link to a new page.
View 2 Replies
View Related
Nov 30, 2010
Is there any method for <input> tag like .html() to escapsing html code? Example with a label, I can use: $("#label").html("NGUYỄN") will become NGUYỄN (that what I want); so I want to do the same thing with <input> tag.
View 1 Replies
View Related
Nov 29, 2010
Here's the setup:
<a href="void();" onClick="jQuery('div#content').load('/cgi-bin/script.pl',{id:$id}); return false;">Link text</a>
Clicking this link works great. The data is loaded into the content div as expected. But the problem is the html that is loaded into the div has funny-looking characters where the single and double quotes should be. (See attachment).
What do I need to do in order to make the quotes show up properly?
Attachments
goofy_quotes.gif
Size : 7.61 KB
Download : 276
View 3 Replies
View Related
Jan 7, 2011
I'm dynamically generating an image tag, and the final slash for self-closing the tag is not coming through, even though the slash is escaped with a backslash. Worse, I think this is screwing up my attempt to select the image in another function. Any ideas what could be causing problems? [code]The image does appear, but I can't reference it later on.While everything works fine if I drop the " img" from the call and let clicking anywhere in the div start the search.Any idea why escaping the slash isn't working?
View 11 Replies
View Related
Mar 1, 2011
I've got this bit of code that I've wrote and it was working absolutely fine like this:
function validatepostcode() {
var postcodevalue = document.getElementById("postcode").value;
if (postcodevalue.indexOf("S") == -1)
{
alert(postcodevalue + " is not a valid postcode.");
[Code]...
What I want to do is wrap the value of "postcodevalue" in double quotes, and since it's inside an alert, I used the escape sequence ", which is how it should be done as far as I know. But for some reason, Dreamweaver's giving me a syntax error warning and the code doesn't work. Am I using the double quotes wrong?
View 23 Replies
View Related
Jan 21, 2007
I have a bookmarklet which copies a marked set of characters into a searchpage in our dictionary. If nothing is copied, a window opens where you can type a word.
BTW, it is for firefox 2.0.
javascript:s=window.getSelection();if(s=='')for(i= 0;i<frames.length;i++){s=frames[i].document.getSelection();if(s)break;}if(!s)void(s= prompt('some
text.',''));if(s){test=open('URL/search.pl?searchphrase='+escape(s));test.focus();}
This works well.
We have another search /command which needs to be finished with &search= after the searchphrase
searchphrase="here comes the markedtyped set of characters"&search=
Can anyone of you help me changing the bookmarklet or point me to a site where I can read more about this?
View 1 Replies
View Related
Jun 22, 2007
Is there a way to create a bookmarklet that discerns the shift (or
ctrl) key state at the time the javascipt is launched?????
View 1 Replies
View Related
Jul 20, 2005
I've found examples of bookmarklets that select a URL from a page at
random, but I'd like one that generates part of the URL at random.
If you have a bunch of images that are named:
mydomain.com/images/abcd.jpg where abcd is can be any combination of 4
lowercase letters - is there a way of having the bookmarklet generate
the letters randomly when clicked?
I'm able to do it using AppleScript & Safari but would like it to work
from within Safari - which is missing the "Scripts" menu that most Apple
apps have :(
It looks as if bookmarklets are the only option, but I've only ever used
javascript to select randomly from existing arrays of images and don't
fancy typing in the names of a couple of thousand images...
View 5 Replies
View Related
May 6, 2003
Download the attached file, rename it read.html and open it. Drag the "read" link onto your Favorites|Links toolbar, and acknowlege the warning dialog. Then, from anyone's page, click the "read" bookmarklet and read along with it.
My basic premise is that vowels and digits make for a place to pause momentarily (90ms) during reading. If it reads too fast or slow, you can adust the delay factor accordingly.
I haven't tested this on other browsers yet.
View 4 Replies
View Related
Mar 3, 2007
I'm using the following javascript bookmarklet for creating del.icio.us posts, and it works fine, but i've been trying to augment it with "document.getSelection" and have not gotten it to work.
the code is:
javascript:q=location.href;p=document.title;void(open('http://del.icio.us/fogboy?v=3&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),'delicious%20',%20'toolbar=no,width=740,height=700'))
and it works fine (to test of course you'd have to change the del.icio.us username in there), except it doesn't have the "document.getSelection" syntax which would make it so highlighted text on a page was put in the "notes" field. i've tried about 5 different ways of writing that, based on other versions i've seen around. i would love to know exactly the right syntax to use to get this working.
View 1 Replies
View Related
Apr 15, 2003
I didn't know about this until a few hours ago. I thought it was cool, so I thought I'd share it.
I got the code from brothercake, although I did add a few tweaks to it.
Just save this as a bookmark, and you can view the source of any site with just a click (even "protected" sites :rolleyes: )
javascript:var newWin=window.open(); newWin.document.body.innerHTML=('<b style="font-family:Verdana; font-size:9pt;">Source of '+location.href+'</b><br><br><br><xmp style="font-family:Verdana; font-size:8pt; color:#000080;"><html>'+document.getElementsByTagName('html')[0].innerHTML+'</html></xmp>'); newWin.select(); newWin.focus(); void(0);
Just remember to remove the space in "javascript:"
View 13 Replies
View Related
Oct 6, 2010
I found this bookmarklet which I'm using in Firefox Would anyone here be willing to modify it to display its results in a new tab, instead of using the current tab?
Code:
javascript:q = "" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); if (!q) q = prompt("You didn't select any text. Enter a search phrase:", ""); if (q!=null) location=("http://www.google.com/search?num=100&q=site:" + escape(location.hostname) + " "" + escape(q.replace(/"/g,"")) + """).replace(/ /g, "+"); void 0
View 1 Replies
View Related
Aug 11, 2006
I'm trying to create a bookmarklet on IE6, that passes the outerHTML of the body element as a GET param my site.
The problem is that for some page (ie mail.yahoo.com) the bookmarklet does not work while for other pages (simpler ones) it does work....
View 2 Replies
View Related
May 6, 2007
javascript:(function(){var k,x,t,i,j,p; for(k=0;x=document.links[k];k+
+){t=x.href.replace(/[%]3A/ig,':').replace(/[%]2f/
ig,'/');i=t.lastIndexOf('http');if(i>0){ t=t.substring(i);
j=t.indexOf('&'); if(j>0)t=t.substring(0,j); p=/https?://[^
s]*[^.,;'%22>s)]]/.exec(unescape(t)); if(p) x.href=p[0]; } else if
(x.onmouseover&&x.onmouseout){x.onmouseover(); if (window.status &&
window.status.indexOf('://')!=-1)x.href=window.status;
x.onmouseout(); } x. x. }})();
View 1 Replies
View Related
Jun 12, 2007
I have bookmarklets with a # in their urls but safari changes the
# to %23. And unfortunately, the bookmarklet does not work with %23.
You need to change it back manually to #.
View 3 Replies
View Related
May 21, 2009
I need this bookmarklet (below) to open in a new window and display the info there. It needs to work in both FF and IE. It would be in one line in the bookmarklet but I expanded it for readability. It should work against our site: [URL]
[Code]...
View 2 Replies
View Related
Aug 6, 2010
How could I make this useful dictionary bookmarklet open in a new window?
javascript:var%20t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));var%20e=(document.charset||document.characterSet);if(t!=''){ location.href='http://translate.google.com/translate_t?text='+t+'&hl=en&langpair=auto|en&tbb=1&ie='+e;}else{location.href='http://translate.google.com/translate?u='+escape(location.href)+'&hl=en&langpair=auto|en&tbb=1&ie='+e;};
Its the "To English" bookmarklet as featured on lifehacker (http://lifehacker.com/5168984/to-english-bookmarklet-quickly-easily-translates-any-text-with-one-click).
View 1 Replies
View Related
Jul 13, 2010
I am trying to write a bookmarklet that extract a citation information from a web page in a new text file for the client by using javascript.
but I could not find any solution where writing to a text file is allowed with firefox by using javascript.
the application suppose to be run on the client side only.
View 2 Replies
View Related
Jul 28, 2011
I have found a script for opening all linked images of one page in a new window and displaying all images in full size inline. It works so far, however:
I want the images to be displays in the current window i am in instead of opening a new window.
Here is the code:
Code:
javascript:(function(){function%20I(u){var%20t=u.split('.'),e=t[t.length-1].toLowerCase();return%20{gif:1,jpg:1,jpeg:1,png:1,mng:1}[e]}function%20hE(s){return%20s.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<').replace(/"
[Code]....
View 3 Replies
View Related
Nov 1, 2009
I am trying to make a twitter bookmarklet that will tweet the current page, I currently have this code:
Javascript:window.open('[URL]'+self.location)
But when I try it, it changes the page its tweeting to just show [object Window].
View 2 Replies
View Related
Apr 4, 2011
I'm not very well versed in javascript. I'm trying to make a bookmarklet that when I click it will either append text to what I've already written or insert the predefined text at the cursor's position in a textarea. Also the browser I'm trying to do this on is Chromium.
Here's what I have:javascript:void((function(){document.getElementsByTagName('textarea')[0].value='ಠ_ಠ'})())
but this of course changes the entire value of the text field to: ಠ_ಠ ...rather than appending or inserting at the cursor position. I'm guessing append would be the simplest, though cursor position would be most efficient.
View 4 Replies
View Related
Aug 14, 2005
In pre-Windows XP Internet Explorer, adding a bookmarklet for a user was
really simple. All I add to do was create a link that executed
addFavorite().
Internet Explorer under Windows XP won't allow that due to its new security
measures.
How can I make adding a bookmarklet convenient for my Windows XP IE users
without having them to do surgery on their security preferences?
Right now I'm having them Ctrl-D to add a new bookmark. Right-click the new
bookmark to get the Properties dialog, and then pasting in the contents of
my bookmarklet. This is quite messy as you can imagine. In addition, when
they save the bookmarklet, they have to hit "Yes" to an error box telling
them that "javascript:" does not have a registered program associated with
it, do they want to save the bookmark anyways?
View 1 Replies
View Related
Feb 9, 2009
I am trying to write a bookmarklet that will let me know an object.For the most part, it works as best I could hope until I try it on a real page.For the purposes of understanding, I am using the Bookmarklet builder here [URL] for testing.
Here is the code:
(function (){
var theObjStr = prompt('What Object would you like to know?','');
var theObj = eval(theObjStr);
[code]....
I compress the code, and test it via the link on the bottom of the page and everything works magically.Add the Bookmarklet to your favorites, and go to [URL] and try to run it in IE7.I am getting an access denied error when the code gets to the line:
var wHndDoc = jjPopWin.document; I have tried everything including just calling a straight
jjPopWin.document.write();
with the same results.
I am on Windows XP SP3, Using IE7 (works great in Firefox 2 &3).
View 5 Replies
View Related
Dec 10, 2009
It would be easier to explain this if you play mafia wars (or any game that includes intra-game exchange of gifts/items between members) but the actual scripting doesn't require any knowledge of the game.
Background Information
Mafia Wars is a game on Facebook (and myspace, yahoo etc.) that among other things allows its players to send gifts to each other. Now because different people end up with more things of one type and are short of things of another type, the players have evolved a trading dynamic. Where x number of Item 1 is traded for y number of Item 2. A simple marketplace. And with this territory come scammers.
Essentially a player who doesn't go through with his end of the deal. good player sends item to bad player. bad player removes good player from mafia and blocks him for ever contacting him through his facebook profile. This has given rise to my group, among many others, that lists these scammers (identified with their facebook profile ids) as they are reported every day. Now over time the list has grown and it has become difficult and unrealistic to expect people to know who is on the list and who is not.
The Requirement
A javascript bookmarklet (there are many already servicing different needs of the players) that sits on the browser and tells the user if the person he is about to trade with is a listed scammer or not.
The Breakdown
The user will click the bookmarklet when he is on the facebook profile of the person he is about to trade with. When clicked the script will pull the facebook profile id from the current page, and then scan a text file located on a third-party server and return with a pop-up box message that reports if the id is listed as a scammer or not.
View 6 Replies
View Related
Jul 23, 2005
I have a problem of escaping quotes in javascript.
Ex:
onclick='alert( "Mister O'Hara" )'
onclick='alert( "Mister O'Hara" )'
both gives me an error. How would I escape this?
View 7 Replies
View Related