# Access Client Side Script

**URL:** https://forum.servoy.com/t/access-client-side-script/13473
**Category:** Classic Servoy
**Created:** [January 19, 2011, 11:25pm UTC](https://forum.servoy.com/t/access-client-side-script/13473 "2011-01-19T23:25:53Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Yummy](https://avatars.discourse-cdn.com/v4/letter/y/7ba0ec/32.png) [@Yummy](https://forum.servoy.com/u/Yummy)
#### Post date: [January 19, 2011, 11:25pm UTC](https://forum.servoy.com/t/access-client-side-script/13473/1 "2011-01-19T23:25:53Z")

</div>

I have an html\_area which I use as an API.

It runs fine however I want to retrieve a value calculated within the client side script, can this be done ?

For example :

```auto
html += globals.glbl_ID+'=data.id;'

```

I’d like to display on my servoy form the value in the global variable globals.glbl\_ID

---

<div class="post-metadata">

### Author: ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)
#### Post date: [January 20, 2011, 12:27am UTC](https://forum.servoy.com/t/access-client-side-script/13473/2 "2011-01-20T00:27:29Z")

</div>

If you are looking for a way to evaluate JavaScript in the browser of a Web client, have a look at the Web Client Utils plugin, on ServoyForge, of course:

> **[Overview - Web Client Utils - ServoyForge](https://www.servoyforge.net/projects/webclientutils)**
>
> Redmine

---

<div class="post-metadata">

### Author: ![Yummy](https://avatars.discourse-cdn.com/v4/letter/y/7ba0ec/32.png) [@Yummy](https://forum.servoy.com/u/Yummy)
#### Post date: [January 20, 2011, 11:48am UTC](https://forum.servoy.com/t/access-client-side-script/13473/3 "2011-01-20T11:48:28Z")

</div>

Not sure I’ve understood how to use the webclientutils ![:(]( "Sad")

Basically I want to get the value of whatever is in the data.id so I was assuming the variable callback would contain this however it contains a load of scripting.

In other words if data.id was 3 then I want the number 3 returned within Servoy.

```auto
markup += 'var id=data.id;'

var callback = plugins.WebClientUtils.addCallback(getID,['id']);

markup += 'function getID(id) {'+callback+'}'

...

function getid(id) {
	
	application.output(id)
}

```

---

<div class="post-metadata">

### Author: ![Yummy](https://avatars.discourse-cdn.com/v4/letter/y/7ba0ec/32.png) [@Yummy](https://forum.servoy.com/u/Yummy)
#### Post date: [January 20, 2011, 2:07pm UTC](https://forum.servoy.com/t/access-client-side-script/13473/4 "2011-01-20T14:07:41Z")

</div>

Ok, I’ve reread whatever documentation I could find and tried various other options includign the following simple test solution which only has a html\_area field defined with the data provider as globals.html.

I’d expect the the getid method to be called but it is not invoked … Sorry but I really have no idea how to get this to work.

```auto
function onLoad() {

var cb = plugins.WebClientUtils.addCallback(getid, ['id']);
var js = 'var id=100;my(id);function my(id){'+cb+'}';
globals.html = '<html><head><script type="text/ javascript">'+js+'</script></head></html>'

}

function getid(){

// I expect id to contain the value 100 but this method is never called

	 var id = arguments[0];
        application ('do I get called ????')
        application.output(id)
}

```

---

<div class="post-metadata">

### Author: ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)
#### Post date: [January 20, 2011, 5:41pm UTC](https://forum.servoy.com/t/access-client-side-script/13473/5 "2011-01-20T17:41:15Z")

</div>

Just tried it here, and this works for me.  
What OS/Browser do you use?

---

<div class="post-metadata">

### Author: ![Yummy](https://avatars.discourse-cdn.com/v4/letter/y/7ba0ec/32.png) [@Yummy](https://forum.servoy.com/u/Yummy)
#### Post date: [January 20, 2011, 6:16pm UTC](https://forum.servoy.com/t/access-client-side-script/13473/6 "2011-01-20T18:16:18Z")

</div>

Am running a web client on developer (v5.21) through Vista and tried it with both Firefox and IE 7.

I also just slightly modified the sample code by adding the alert, I get the alert displayed but the method is not called (no application.ouitput debug info).

```auto
var jsToExecute = "alert('help');var sum = 1 + 2";

plugins.WebClientUtils.executeClientSideJS(jsToExecute, getid, ['sum'])

}

/**
 * @properties={typeid:24,uuid:"17B737FE-3A5B-47F3-AA0B-9A4AD1AEAE12"}
 */
function getid(){

// I expect id to contain the value 100 but this method is never called

    var id = arguments[0];
        application ('do I get called ????')
        application.output(id)
}

```

---

<div class="post-metadata">

### Author: ![Yummy](https://avatars.discourse-cdn.com/v4/letter/y/7ba0ec/32.png) [@Yummy](https://forum.servoy.com/u/Yummy)
#### Post date: [January 20, 2011, 6:41pm UTC](https://forum.servoy.com/t/access-client-side-script/13473/7 "2011-01-20T18:41:09Z")

</div>

Just tried it on a W7 machine and it works. At least that gives me soemthign to go on.

---

<div class="post-metadata">

### Author: ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)
#### Post date: [January 20, 2011, 6:54pm UTC](https://forum.servoy.com/t/access-client-side-script/13473/8 "2011-01-20T18:54:31Z")

</div>

Hum, yes. I tested on Win 7. Will give it a go on Vista but that’s very strange that there would be any differences.  
What Servoy version do you use on 7?

---

<div class="post-metadata">

### Author: ![Yummy](https://avatars.discourse-cdn.com/v4/letter/y/7ba0ec/32.png) [@Yummy](https://forum.servoy.com/u/Yummy)
#### Post date: [January 20, 2011, 7:12pm UTC](https://forum.servoy.com/t/access-client-side-script/13473/9 "2011-01-20T19:12:52Z")

</div>

same version both running 5.2.1.

Just even did a reinstall oif 5.2.1 on Vista as I had to install Servoy on the W7 machine. With Vista it does not work.

---

<div class="post-metadata">

### Author: ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)
#### Post date: [January 20, 2011, 7:49pm UTC](https://forum.servoy.com/t/access-client-side-script/13473/10 "2011-01-20T19:49:03Z")

</div>

Yes, I just saw that, tried with Vista/Servoy 5.2.1/IE8.

Actually the problem seems to be coming from the callback in the onLoad/onShow function.  
If you do the same script from another type of event (try calling it from a button but with no onLoad call), this works on Vista as well…

I know that there was something fishy about it and I coded a workaround specifically , but I would never have imagined that it would react differently depending on the client OS platform.  
I have tested on Win XP and Win 7 with IE7/8 - Firefox 3.6 - Chrome 8 and Mac OS X Snow Leopard with Safari 5 and Firefox 3.6 and didn’t encounter the problem.

Will have a better look at that call from onLoad/onShow, to find a better workaround.

---

<div class="post-metadata">

### Author: ![Yummy](https://avatars.discourse-cdn.com/v4/letter/y/7ba0ec/32.png) [@Yummy](https://forum.servoy.com/u/Yummy)
#### Post date: [January 20, 2011, 8:23pm UTC](https://forum.servoy.com/t/access-client-side-script/13473/11 "2011-01-20T20:23:33Z")

</div>

Thanks for the help.
