Distinguish 2 publications online script

thomasnowac

New member
Is it possible to set a global variable in HE and to retrieve it in JavaScript in real time?

The situation I have is that JavaScript htmlexe.GetGlobalVariable is asynchronous, which it did not used to be in Html Executable 4.x. window.external.GetGlobalVariable('HE','she') worked. Now you need a callback function, as I understand it.

function heservr(content) {alert(content)} // callback
htmlexe.GetGlobalVariable('henew', '', heservr);

Provided the value of henew is 'www', there is an alert to that effect when you go to the page containing the JS. This is asynchronous. The page loads first, then the alert.

What I would like to do is to detect if henew = 'www1' or henew = 'www2' in two publications. In publication A the value is www1 and publication B www2. When the publications go to a page that is online they should behave in different ways. Publication A is allowed to open a link and B cannot open the same link. The online server needs to detect which is which. Asynchronous detection does not work here, because the page with the link loads beforehand.

So my question is, I guess, whether there is some way to retrieve a string or a variable stored in a publication before the page loads. Please do note that the publications are mostly self-contained. Visiting the online page is the exception.

The online page can detect Html Executable, but not which publication.
 
Last edited:
Solution
Well, I spent a long weekend and then some on this. The best I can come up with is:
localHE=(typeof htmlexe != 'undefined')?true:false;
Useful if you aim to go online in a publication and disable specific links, for example, to Amazon or Paypal on the site that you’re linked to.

If anyone can offer a better detection script, that would be excellent. I will leave this open.
Well, I spent a long weekend and then some on this. The best I can come up with is:
localHE=(typeof htmlexe != 'undefined')?true:false;
Useful if you aim to go online in a publication and disable specific links, for example, to Amazon or Paypal on the site that you’re linked to.

If anyone can offer a better detection script, that would be excellent. I will leave this open.
 
Solution
Sorry to bother you @ thomasnowac but scripting is my weak area. Possible to give full working example? My old head is not digesting this :>}

localHE=(typeof htmlexe != 'undefined')?true:false;
Useful if you aim to go online in a publication and disable specific links, for example, to Amazon or Paypal on the site that you’re linked to.
 
The principle of disabling links online when users navigate to your website from an Html Executable publication directly, which they are able to do, if you link to it, is interesting in itself. Suppose someone is browsing in Html Executable, your publication, and they decide to visit their bank online and to transfer money. If something should go amiss in that transfer, you might be held culpable.

My site that I link to is pretty isolated. There are few links to other sites. Amazon links send you to a page to buy an e-book. PayPal links let you buy an image via Instant Payment. With the Amazon links it is possible to include a script that would open the link in the user’s browser instead of the publication.

var blank = (hes4||localHE) ? '_heexternal' : '_blank';

'_heexternal' is Html Executable’s way of opening browser windows.

Unless I’m mistaken, Edge or Chrome, if the publication is Html Executable 5, or IE, if the publication is Html Executable 4.x.

PayPal links to instantly buy an image cannot open in a new browser window. PayPal would not allow it. The link opens in the browser where the link is clicked, since there is then a connection to the item being purchased.

To make a long story short, I disable external links (PayPal and Amazon) for Html Executable:

function obj(id) {return d.getElementById(id)}
if (hes4||localHE) {
if (d.getElementById('ext01')) {obj('ext01').style.display='inline-block';obj('ext01').style.pointerEvents='none';}
}

If you really wanted to, you could even make the button disappear completely.

What kind of threw me, was 'undefined' in single quotes. Normally in JS it should be:

localHE=(typeof htmlexe != undefined)?true:false;

Without quotes. But if it works it works,
localHE=(typeof htmlexe != 'undefined')?true:false;
 
Back
Top