[ 3 posts ]

Allan

  • Username: Allan
  • Joined: Sun Feb 20, 2011 5:55 am
  • Posts: 1
  • Offline
  • Profile
Tags:

How to run the javascript in external HTML in tabviw?

Post Posted: Sun Feb 20, 2011 6:02 am
+0-
I wrote a tabview( YUI3.3 ) content external HTML,but the problem is:how can I run the javascript in the HTML without dispather? Does YUI3 support this feature
Thank you.

Marco Asbreuk

YUI Contributor

  • Username: itsasbreuk
  • Joined: Mon Nov 16, 2009 5:14 am
  • Posts: 459
  • Location: Netherlands
  • Twitter: itsasbreuk
  • GitHub: ItsAsbreuk
  • Gists: ItsAsbreuk
  • IRC: Marco Asbreuk
  • Offline
  • Profile
Tags:

Re: How to run the javascript in external HTML in tabviw?

Post Posted: Tue Feb 22, 2011 11:53 am
+1-
Hey Allan,

If you want to execute the script, you need to insert it as a node.
Something like:
Code:
var head = Y.one('head');
var scriptnode = '<script>' + myscriptcode + '</script>';
head.appendChild(scriptnode);
// removing script after being excuted
scriptnode.remove();

However, the </script> will break your own code, thus you should use:
Code:
var SC = 'script';
var head = Y.one('head');
var scriptnode = '<' + SC + '>' + myscriptcode + '</' + SC + '>';
head.appendChild(scriptnode);
// removing script after being excuted
scriptnode.remove();

Next thing is that you probably don't know the script, so you will have to extract it from your external source.
If you are at this stage, than I would suggest to use dispatcher indeed. This module is very robust well-tested and light-weight. Why don't you want to use it?

Kind Regards,
Marco.

Caridy Patino

YUI Contributor

  • Username: caridy
  • Joined: Mon Dec 08, 2008 5:40 pm
  • Posts: 493
  • Location: Miami, FL
  • Twitter: caridy
  • GitHub: caridy
  • Gists: caridy
  • IRC: caridy
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: How to run the javascript in external HTML in tabviw?

Post Posted: Mon Feb 28, 2011 8:58 pm
+0-
Yeah, why don't you want to use it? :)

Best Regards,
Caridy
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum