TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   Problem Passing Data Dynamically in Java (http://forums.techarena.in/software-development/1148317.htm)

Kushan 26-03-2009 02:19 PM

Problem Passing Data Dynamically in Java
 
I am having a big trouble in java orinted platform. I am totally confused as how to pass data from javascript to server.

I really don't have any idea regarding java script and java programming. Please provide some assistance regarding this problem

Please help

Zecho 26-03-2009 02:24 PM

Re: Problem Passing Data Dynamically in Java
 
The usefulness of being able to dynamically load a style sheet is fairly limited, but there is one very good reason to keep this tool handy: it lets you load a specific stylesheet for a specific browser. Instead of having one massive style sheet for every browser which visits your page, you can break out the stylesheets into browser specific Firefox, IE, Safari, Opera, etc styles which accommodate the eccentricities of each browser and let you serve smaller css files to your visitors to boot.

Reegan 26-03-2009 02:25 PM

Re: Problem Passing Data Dynamically in Java
 
PHP Code:

var headID document.getElementsByTagName("head")[0];         
var 
cssNode document.createElement('link');
cssNode.type 'text/css';
cssNode.rel 'stylesheet';
cssNode.href 'FireFox.css';
cssNode.media 'screen';
headID.appendChild(cssNode); 


opaper 26-03-2009 02:26 PM

Re: Problem Passing Data Dynamically in Java
 
PHP Code:

var headID document.getElementsByTagName("head")[0];         
var 
newScript document.createElement('script');
newScript.type 'text/javascript';
newScript.src 'http://www.somedomain.com/somescript.js';
headID.appendChild(newScript); 

It's really that simple. headID gets the <head> element of the page. Next we create a new 'script' element, assign it a text/javascript type, and then the url of the script (which can be anywhere on the net since it's basically a javascript include). Finally we append the new element to our head section where it is automatically loaded.

If you're loading an external javascript and you need to know when the script has loaded you can simply use .onload=yourfunction; to set up the onload handler. Here's an example.

PHP Code:

var headID document.getElementsByTagName("head")[0];         
var 
newScript document.createElement('script');
newScript.type 'text/javascript';
newScript.onload=scriptLoaded;
newScript.src 'http://api.flickr.com/services/feeds/photos_public.gne?tags=sunset&format=json';
headID.appendChild(newScript); 



All times are GMT +5.5. The time now is 03:15 AM.