javascript - How to use one single Prototype-Instance throughout multiple HTML pages? -
i created javascript "classes" within own files using prototype function this:
function playlist(id, name){ this.id = id; this.name = name; } playlist.prototype.getid = function(){return this.id;} playlist.prototype.getname = function(){return this.name;}
i create instances of "class" this:
var playlist = new playlist();
is there possible way can use 1 single instance throughout multiple html pages? tried this:
"<a href='next.html?pl="+playlist+"'>next</a>"
but gives me [object, object] can't anything. appreciate solutions.
no, there no way pass javascript function instances on http. json not serializes properties , not methods. can serialize function declarations , recreate them via eval
, evil , not want anyway.
two possible solutions are:
- keep on single page. single page apps popular. load need load asynchronously , still have access
playlist
instance on page. - pass properties (
id
,name
) need recreate object instance on http instead, create instance on next page.
Comments
Post a Comment