Hi,
The following bookmarklet code is modified from the Library Lookup Project.
The 1st 2 lines of the code below extracts a book's ISBN number (worldwide unique ID) from a book's page on a site like Amazon. (It gets the ISBN from the page's URL).
The next 2 lines open a new browser window showing my local library's search page.
Now to get the library's site to search on the ISBN used to be easy, just format a search URL with the ISBN in the right place and that's it. Now they've changed the system and need a form posted. So the code starting with '<body onload...' should submit the form data and so start the search.
javascript:var re=/([\/-]|is[bs]n=)(\d{7,9}[\dX])/i;
if(re.test(location.href)==true){var isbn=RegExp.$2;
void(win=window.open(''LibraryLookup','scrollbars=1,resizable=1,location=1,width=575,height=500'));
'<body onload="document.forms[0].submit()"> <form Method="post"
action="<input name="searchType" value="advSearch" />
<input name="st1" value="controlNumber" />
<input name="sv1" value=isbn />
<input name="sb1" value="And" />
<input name="st2" value="title" />
<input name="sv2" value="" />
<input name="sb2" value="And" />
<input name="st3" value="author" />
<input name="sv3" value="" />
<input name="searchLocation" value="talislms" />
<input name="searchCollection" value="1" />
<input name="searchSites" value="-1" />
<input name="searchDates" value="" />
<input name="searchManualDate" value="" />
<input name="searchLanguages" value="" />
<input name="searchFormats" value="" />
<input name="searchOPUS" value="" />
<input name="pageSize" value="20" />
</form></body>';}
There are 2 problems with the code which I can't fix.
i) Firstly the new window showing the library's search page opens but the form gets posted to the original page, the one that was being displayed when the bookmarklet was clicked. I can't work out how to alter the code to make the form get posted to new opened window. Any ideas?
ii) In the form posting code, 5th line down, the value of 'sv1' should be set to the value of the variable isbn (defined in the 2nd line of code at the end of the line), this is the books ISBN number to search for. However in my code the actual letters 'isbn' are posted to the form and not the contents of the isbn variable. What have I done wrong?
Many thanks for any assistance for a javascript newbie.
Regards, etc..
The following bookmarklet code is modified from the Library Lookup Project.
The 1st 2 lines of the code below extracts a book's ISBN number (worldwide unique ID) from a book's page on a site like Amazon. (It gets the ISBN from the page's URL).
The next 2 lines open a new browser window showing my local library's search page.
Now to get the library's site to search on the ISBN used to be easy, just format a search URL with the ISBN in the right place and that's it. Now they've changed the system and need a form posted. So the code starting with '<body onload...' should submit the form data and so start the search.
javascript:var re=/([\/-]|is[bs]n=)(\d{7,9}[\dX])/i;
if(re.test(location.href)==true){var isbn=RegExp.$2;
void(win=window.open(''LibraryLookup','scrollbars=1,resizable=1,location=1,width=575,height=500'));
'<body onload="document.forms[0].submit()"> <form Method="post"
action="<input name="searchType" value="advSearch" />
<input name="st1" value="controlNumber" />
<input name="sv1" value=isbn />
<input name="sb1" value="And" />
<input name="st2" value="title" />
<input name="sv2" value="" />
<input name="sb2" value="And" />
<input name="st3" value="author" />
<input name="sv3" value="" />
<input name="searchLocation" value="talislms" />
<input name="searchCollection" value="1" />
<input name="searchSites" value="-1" />
<input name="searchDates" value="" />
<input name="searchManualDate" value="" />
<input name="searchLanguages" value="" />
<input name="searchFormats" value="" />
<input name="searchOPUS" value="" />
<input name="pageSize" value="20" />
</form></body>';}
There are 2 problems with the code which I can't fix.
i) Firstly the new window showing the library's search page opens but the form gets posted to the original page, the one that was being displayed when the bookmarklet was clicked. I can't work out how to alter the code to make the form get posted to new opened window. Any ideas?
ii) In the form posting code, 5th line down, the value of 'sv1' should be set to the value of the variable isbn (defined in the 2nd line of code at the end of the line), this is the books ISBN number to search for. However in my code the actual letters 'isbn' are posted to the form and not the contents of the isbn variable. What have I done wrong?
Many thanks for any assistance for a javascript newbie.
Regards, etc..