jungleGuru Posted September 3, 2008 Share Posted September 3, 2008 I've been working a lot lately with the dynamic output of my javascript based on my PHP classes. Viewing the source is pretty messy, but the ease and adaptability of my javascript code is beautiful. To the point: I just found that there is a method in ASP called RegisterClientScriptBlock that allows client side code to be registered with the browser. I am guessing that the code would not be visible by viewing the page source; and I would think that the page would load faster since the browser is being 'force fed' instead of having to read the code in the source, determining where HTML stops and jscript begins, extra decisions that can add up, yadda yadda. I did a search in this form for "RegisterClientScriptBlock" and found no results; guessing that if it's being talked about, that string would be used. I also searched the web for "RegisterClientScriptBlock Equivalent for PHP" ... nada. So what's up? Thanks The Jungle Guru ⼿⽊⽣ Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 3, 2008 Share Posted September 3, 2008 I'm not entirely sure what you are trying to do, but I get the feeling that AJAX is what you are looking for. http://en.wikipedia.org/wiki/AJAX Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted September 3, 2008 Share Posted September 3, 2008 I've been working a lot lately with the dynamic output of my javascript based on my PHP classes. Viewing the source is pretty messy, but the ease and adaptability of my javascript code is beautiful. To the point: I just found that there is a method in ASP called RegisterClientScriptBlock that allows client side code to be registered with the browser. I am guessing that the code would not be visible by viewing the page source; and I would think that the page would load faster since the browser is being 'force fed' instead of having to read the code in the source, determining where HTML stops and jscript begins, extra decisions that can add up, yadda yadda. I did a search in this form for "RegisterClientScriptBlock" and found no results; guessing that if it's being talked about, that string would be used. I also searched the web for "RegisterClientScriptBlock Equivalent for PHP" ... nada. So what's up? Thanks The Jungle Guru ⼿⽊⽣ From what little I know of .NET (currently enrolled in an ASP.NET 3.5/C# class), I'm somewhat familiar with what you're asking. No, there's no built-in function to register your JavaScript with PHP, at least, none that I know of. You can simply put it all in an external library file, or within a static header file that's included with each page. Or, if you need to write the JavaScript dynamically, you'll have to roll up your sleeves and write it directly using echo, print, or a HEREDOC. There's no real clean way to doing it that way, I'm afraid. Hey, mind telling me in a private message why registering client-side scripts with the server would be a good thing? My book describes how to do it by using one of the three Register methods, but not why I'd want to. It doesn't even mention what registering a script does! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.