/    Sign up×
Community /Pin to ProfileBookmark

Search Buffer in JavaScript

Here is my function to pdfs. I use a string buffer to take values from the search boxs to make the search parameter for when it opens. I got the code for the buffer online because there isnt anything built in, and im not sure if i’m using it correctly.

[CODE]
function openPDFWord(thisObj, pdfURL) {
//For Opening PDF files
function StringBuffer() {
this.buffer = [];
}
StringBuffer.prototype.append = function append(string) {
this.buffer.push(string);
return this;
};
StringBuffer.prototype.toString = function toString() {
return this.buffer.join(“”);
};
var searchA = document.getElementById(“form1:hiddenAllWord”).value;
var searchE = document.getElementById(“form1:hiddenExactPhrase”).value;
var searchT = document.getElementById(“form1:hiddenAtLeastOneWord”).value;
if(searchA != null || searchE != null ||searchT != null){
if(searchA != null)
buf.append(searchA);
if(searchE != null)
buf.append(searchE);
if(searchT != null)
buf.append(searchT);
}
search = buf.toString();
if (search != null) {
search = “#search=%22” + search + “%22”;
return search;
} else
search = null;
formTitleId = thisObj.id.substr(0,thisObj.id.lastIndexOf(‘:’)) + “:hiddenFormTitle”;
formTitle = document.getElementById(formTitleId).value;
globalHTML=”<html><head><title>” + formTitle + “</title></head>”
+”<frameset><frame src='” + pdfURL + “‘></frame>”
+”</frameset></html>”;
window.open(“javascript:opener.globalHTML”,”_blank”,”resizable=yes,menubar=yes,toolbar=no”);
return false;
}

[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @cip315 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...