humanfly199
Technical User
Hi, will someone please help with this.
The code prompts a pop up search box and if text is selected on a page it will be in the box automatically. (It's for a firefox extension)
I want to avoid the prompt if text is selected, so it will only prompt if nothing is selected. I think that I need to use "if & void" but I dont understand how to put it in there. The bookmarklet below does this perfectly. Will someone please help?
The Code..
Here's a bookmarklet I found that uses this feature
The code prompts a pop up search box and if text is selected on a page it will be in the box automatically. (It's for a firefox extension)
I want to avoid the prompt if text is selected, so it will only prompt if nothing is selected. I think that I need to use "if & void" but I dont understand how to put it in there. The bookmarklet below does this perfectly. Will someone please help?
The Code..
Code:
function srch() {
var query = window._content.document.getSelection();
var revQuery = prompt("Search eBay", query);
if (revQuery != null) {
var myURL = "[URL unfurl="true"]http://search.ebay.com/search/search.dll?query="[/URL] + revQuery;
openNewTabWith(myURL, null, null, true);
}
}
Here's a bookmarklet I found that uses this feature
Code:
javascript:if(frames.length>0){F=' (Open frame in new window first.)'}else{F=''}Q=document.getSelection();if(!Q){void(Q=prompt('No text selected on page.'+F+'\n\nKeywords...?',''))};if(Q)location.href='[URL unfurl="true"]http://bookmarklets.com/moreinfo.phtml?q='+escape(Q)[/URL]