Hi,
we just recently updated to Flare Version 8 and changed our Output from "normal" WebHelp to HTML5 Output.
My question is: Is there any possiple way to fire a javascript event (onClick or smth similar) when someone searches something in our WebHelp? In our old Output the Javascript was implemented into the MadCallAll.js file. But in the HTML5 output this file is generated while compiling - so it gets overwritten every time I am building my output.
Does anyone have an idea?
I am looking forward for any helpful response you can offer!
Thanks
Best regards.
Fire Javascript Event on Search (HTML5)
Re: Fire Javascript Event on Search (HTML5)
Hi Thomas,
Firstly, are you aware that you can specify custom JavaScript in HTML5 skins by entering it in the Toolbar settings? -
To run a custom function on page load, you need to use this syntax:
Note that you mustn't include brackets in the window.onload statement: you're not calling the function here, you're assigning it.
Regarding your query about firing an onClick event: you could use JavaScript to add an onclick handler to the search submit button, which in turn invokes the click() method of the element that you want to receive the simulated click. E.g.
There is a succinct explanation of the click() method here: http://www.randomsnippets.com/2008/03/0 ... avascript/
Firstly, are you aware that you can specify custom JavaScript in HTML5 skins by entering it in the Toolbar settings? -
To run a custom function on page load, you need to use this syntax:
Code: Select all
function myCustomStuff() {
... Stuff ...
}
window.onload=myCustomStuff;Regarding your query about firing an onClick event: you could use JavaScript to add an onclick handler to the search submit button, which in turn invokes the click() method of the element that you want to receive the simulated click. E.g.
Code: Select all
function customiseSubmit() {
// Locate the search button. NB getElementByClass isn't a standard JavaScript function - see below.
searchButton = getElementByClass("div", "search-submit");
// Add an onclick handler to the submit button, that runs the function which simulates the click:
searchButton.onclick = simulateClick();
}
function simulateClick() {
// Locate the element that you want to receive the simulated click:
receiverElement = ### YOUR CODE HERE ###;
receiverElement.click();
}
function getElementByClass(element, class) {
// You'll need to implement this function yourself. PM me if you want tips.
... Stuff ...
}
window.onload=customiseSubmit;You do not have the required permissions to view the files attached to this post.
Re: Fire Javascript Event on Search (HTML5)
Hi Franky,
thank you very much for you response.
I was aware that I could specify custom Javascript in the skin but we were missing the wood for the trees and couldn't think of any way to adress the button.
Your approach was exactly what we needed and with some modifications we were able to implement the script just as we wanted.
Again, thank you for your comment!
thank you very much for you response.
I was aware that I could specify custom Javascript in the skin but we were missing the wood for the trees and couldn't think of any way to adress the button.
Your approach was exactly what we needed and with some modifications we were able to implement the script just as we wanted.
Again, thank you for your comment!
Re: Fire Javascript Event on Search (HTML5)
No problem, and glad you could make sense of my answer! I'd needed to do something very similar myself, so fortunately it was fresh in my mind.