NetTalk Central

Author Topic: How to include script to HEAD tag of specific page  (Read 5304 times)

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
How to include script to HEAD tag of specific page
« on: September 07, 2011, 12:22:55 PM »
Hi,

as subject says, is there any way to include script into <head> tag of some page that needs it - not for all pages.

Thanks
Alex

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to include script to HEAD tag of specific page
« Reply #1 on: September 07, 2011, 09:41:03 PM »
Hi Alex,

what template type is the page? netWebPage? netWebForm? NetWebBrowse?

Cheers
Bruce

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Re: How to include script to HEAD tag of specific page
« Reply #2 on: September 08, 2011, 07:25:12 AM »
Hi Bruce,

netWebForm, But I guess I asked dumb question, cause my form should be embedded into netWebPage and it has After <head>  location for XHTML routine. Can you please confirm this.

thanks,
Alex

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Re: How to include script to HEAD tag of specific page
« Reply #3 on: September 08, 2011, 07:36:09 AM »
On the second thought, netWebBrowse is calling update form which is netWebForm type. So I need to put script in the head section for the form.

Thanks,
Alex

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Re: How to include script to HEAD tag of specific page
« Reply #4 on: September 14, 2011, 08:34:57 AM »
Hi Bruce,
Maybe I was not clear after all posts I added. I need to put script in the head section for the netWebForm. I need your suggestion on how to do it please.

Thanks,
Alex

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to include script to HEAD tag of specific page
« Reply #5 on: September 14, 2011, 10:26:00 PM »
Hi Alex,

The thing is - a Form doesn't have a <head>.
Fundamentally a Form is just a control, not a page. It's designed to be "used" on a page, sometimes with lots of other "controls" (Browses & Calendars are also  controls).

Now it's true you can call controls as a page (this is handled by a generic page wrapper constructed by the MakePage method) - but they can also be called in other ways - for example as a popup.

To answer your question properly I'd need a bit more information, but here are two tidbits you may or may not be aware of;

a) If it's an actual <script> function, or code, you are trying to embed, it can go anywhere on the page. Ideally you add it using the NetTalk .Script method in the form itself. So, for example, say you had a script like this;

<script>
  alert("Boks to win RWC");
</script>

Then you can add it to the form as either;

packet = clip(packet) & p_web.Script('alert("Boks to win RWC");',net:NoSend)

or

p_web.Script'alert("Boks to win RWC");'

You can put this pretty much where you want it to go - for example, if you want it to run when the form is displayed then put it in GenerateForm, or if when a field is completed, then put it in the Validate::FieldName routine.

Cheers
Bruce


alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Re: How to include script to HEAD tag of specific page
« Reply #6 on: September 15, 2011, 06:56:03 AM »
Thanks Bruce,

the reason I was asking this despite the fact that netWebForm is a "control" as you said is because I wanted to use some scripts for image gallery within a form. However, examples for implementing each of these scripts start by adding some code within the <head> tag of the page itself. Since I'm no expert for javascript and web in general I was following the instructions :) ... hence my question. I was also aware that netWebForm is somehow wrapped in the generic web page but I was thinking that it is possible to tweak the header itself on a page basis. I will try putting script on the page as you suggested and see what happens.

Thank you very much for your time.

Regards,
Alex