DriverTable - Scan Driver String with Javascript Bookmarklet

AceInfinity

Emeritus, Contributor
Joined
Feb 21, 2012
Posts
1,728
Location
Canada
Here's a little bookmarklet javascript code I developed which will take the selected text on the webpage, and use it as the id= in the DriverReference Table. So if somebody posts a driver onto a page, you can highlight it with your ibeam, then click your little javascript bookmark, and it will go to that driver's page in the DRT, assuming it exists

:beerchug2:

Code:
javascript:var t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));t=String(t).replace(/^\s+|\s+$/g,'');if(t!=''){(function(){ window.open('https://www.sysnative.com/drivers/driver.php?id='+t); })();}else{alert('Please select/highlight a driver on the page first!');};

Bookmarklets don't work in IE.

Go create your bookmarklet :)
HOQon.png


It's on my Chrome bookmarks bar.
 
What browser are you using Carrona? (I believe this only works in FF/Chrome)

Anyway, first thing to do is to create a new bookmark with the following web address
Code:
javascript:var t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));t=String(t).replace(/^\s+|\s+$/g,'');if(t!=''){(function(){ window.open('https://www.sysnative.com/drivers/driver.php?id='+t); })();}else{alert('Please select/highlight a driver on the page first!');};
What this will allow the browser to do is run the javascript every time you click on the bookmark in the browser.

In order to make the javascript work correctly you select the driver name then click the bookmark...

Example:
Code:
8042pr2.Sys
Highlight the above driver name then click the bookmark.

I can confirm it working here in FF/Chrome
 
Oh ok, I will fix it for you

Try this:
Code:
javascript:var t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));t=String(t).replace(/^\s+|\s+$/g,'');if(t!=''){(function(){ window.open('http://www.carrona.org/drivers/driver.php?id='+t); })();}else{alert('Please select/highlight a driver on the page first!');};
 
Thanks a lot for this :)

I even got it working in IE9!

Alt > View > Toolbars > Favorite bar

Visit the DRT (to get the correct favicon) > click on the left most button in the Favorites toolbar ("Add to Favorites Bar")

Right click on it > Properties > Web Document tab > URL: Paste in the Javascript > General tab > Give it a name > OK.

Easy! Thanks again for this :)
 
I don't use IE very often, but I was under the impression that IE didn't allow javascript in bookmarklets for security reasons. Nice to know it's possible in IE9 :)
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top