custom buttons and javascript in HTML5

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
bill b
Propeller Head
Posts: 56
Joined: Mon Feb 04, 2013 12:47 pm

custom buttons and javascript in HTML5

Post by bill b »

Hi,

This code works in a browser:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="javascript">
<!--
function getPdf() {
alert("hello");
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="Button" NAME="PDF" onclick="javascript:getPdf();">
</FORM>
</BODY>
</HTML>

</body>
</html>

But when I insert into the javascript window in the HTML5 skin editor, nothing happens.

So, what do I need to know--other than javascript itself--about how javascript code interacts with an HTML5 skin?

TIA,
Bill
bill b
Propeller Head
Posts: 56
Joined: Mon Feb 04, 2013 12:47 pm

Re: custom buttons and javascript in HTML5

Post by bill b »

I'll partially answer my own question: when I look at the source code for the HTML5 skin toolbar, it's naming the button I created "button-pdf" I called it "PDF"

So, it appears that there is javascript infrastructure in the HTML5 skin that I need to know about. It isn't a question of knowing javascript, but knowing what Flare is expecting to see in the "INPUT" line. This is something that should be documented somewhere, right?
bill b
Propeller Head
Posts: 56
Joined: Mon Feb 04, 2013 12:47 pm

Re: custom buttons and javascript in HTML5

Post by bill b »

sorry to run on, but I've seen partial solutions on blogs about this, where a call is added to "event" in the style properties of the button. This will not work for me: it's static. I need a dynamic solution that opens different pdfs based on where I'm at in the skin's html pages. the javascript code for this is no problem for me, but I can't seem to find the answer to this basic question:

In the skin editor, when I create a button, "foo", what do I need to know, from the Flare end, to link a click of a button to a javascript action (i.e., a call to some javascript function that I wrote). What is the right name of the button, the class, whatever I need to know to get the javascript to be aware that button "foo" was clicked--what does javascripts "onclick" need to know exactly?

Thanks for any help.
bill b
Propeller Head
Posts: 56
Joined: Mon Feb 04, 2013 12:47 pm

ANSWER!!!

Post by bill b »

My good friend Sarat in QA helped me find an answer:

http://tregner.com/flare-blog/

The bottom line is that you have to place a function call in the "click" property in the style properties associated with your new button.

event: get_pdf();

in my case. That calls the javascript function and allows me to do any dynamics I want. Also, you don't need to put anything in the javascript window other than

function get_pdf(){

*****javascript code here *******;

}

I hope this is of some help to somebody other than me.

Cheers,
Bill
Jordan
Jr. Propeller Head
Posts: 1
Joined: Wed Jun 27, 2018 6:16 am

Re: custom buttons and javascript in HTML5

Post by Jordan »

It's been a long time since the last post but I currently face the same challenge as bill b (opening different PDFs to a new browser tab depending on the page the user is on). I conditionally tagged the topics that will be related to each PDF link. Then I created a button in the unique TopicTooolbar skin and set the event script to "get_pdf();" as suggested in the previous post. Now, I have to define this function's content in the Custom Javascript area of the skin's Setup tab. I don't really know javascript but I suppose the logic of the script should be like this:

function get_pdf(){
if tag condition is A then window.open ("https://mysite.org/documentA.pdf);
if tag condition is B then window.open ("https://mysite.org/documentB.pdf);
etc.
}

How do I link the condition of the underlying topic to the script? Any help would be highly appreciated.

Thanks,
Jordan
Post Reply