1 edb May 06, 2007 00:08
3 balupton May 06, 2007 13:28
So right now you have all your javascript scripts in one file, and each script is blog specific?
Well trans does allow scripts in the body tag. (At least to my knowledge).
But couldn't what you do is have seperate javascript files for each page, and then just include the appropriate one for the current blog via php, instead of just including them all for one blog?
4 yabba May 06, 2007 14:30
$disp is set waaaaay before the skin is called ?
¥
5 edb May 06, 2007 15:41
All in one blog - just different values of disp. So I'm thinking it'll be neater if the visitor only has to download the javascript they need for the page they're seeing. Especially since it's only 3 pages in my hackblog. Thus moving the javascript into the body, which means into the page called by the value of $disp.
Yeah I thought it would be a no-brainer to have "if( $disp == 'foo' ) { whatever }" in the head section, but it didn't work. It did not include the javascript that the whatever bit wanted, so I went with "if( $blog == 2 ) { whatever }".
I'll try it again because I might have done something wrong the first time. Something simple like echoing a stupid author tag should do for testing.
be right back ...
6 laibcoms May 06, 2007 15:50
XHTML 1.0 Transitional, if I remember correctly it is fine to put JS within the body element, I think up to XHTML 1.0 Strict it's allowed. With XHTML 1.1 (which is strict only), not sure, haven't touch that version yet.
Probably its fine, especially since there are still many services that use JS within the body element. Regardless, it doesn't hurt to disobey W3C for one unavoidable code ;) sometimes they really make decisions that are err... example: removing the target attribute :p (target="") under XHTML 1.0 and above. :p
7 edb May 06, 2007 16:07
Okay so this is how it was when it was based on $blog:
<?php if( $blog == '2' ) { ?>
<script type="text/JavaScript" src="various_scripts.js">
</script>
<?php } ?>
Placed more or less right before the /head tag.
So I changed it to this:
<?php if( $disp == 'metatags' ) { ?>
<script type="text/JavaScript" src="js_metatags.js">
</script>
<?php } ?>
<?php if( $disp == 'password' ) { ?>
<script type="text/JavaScript" src="js_password.js">
</script>
<?php } ?>
<?php if( $disp == 'powerball' ) { ?>
<script type="text/JavaScript" src="js_powerball.js">
</script>
<?php } ?>
In the same place.
And ... uh ... it works. Just like one would expect it to. Reckon I did something painfully stupid that I accidentally corrected when I tried using $blog instead of $disp.
duh.
Next I need to figure out why my popup for powerball numbers launches a new tab and never finishes loading even though it's done filling up with numbers. Probably works in IE, but not FF. Probably something really simple too. Probably oughta not launch a popup for the numbers though. Oughta just fill in a textarea, but I'm really not into put a lot of effort into the page or the script - just wanted it to play nice in my blog ya know?
ACTUALLY the next thing I need to do is figure out how to have an included page that can have comments and trackbacks and stuff. Like a post only not a post eh? It's a major flaw in b2evolution to not have the ability to throw down an "about me" (or similar) page, but it's even worse that I can do it but can't get comments on it. Along that line I'm thinking of a post with no content and a bit in the post loop that says "if post_ID == NN then include this page instead of all the other stuff you normally do". Seems like a win-win to me because it would all be in the skin.
(Did I just give away my next great hack?)
Hey thanks guys! Now I know I probably could get away with putting the javascript back into the specific page, which would reduce my total number of files and simplify my skin, AND I know I can tweak my head section based on the value of $disp.
MISSION ACCOMPLISHED!
8 yabba May 06, 2007 16:29
Next I need to figure out why my popup for powerball numbers launches a new tab and never finishes loading even though it's done filling up with numbers.
I've not looked at your script, but if you do something like document.write(); you also need to document.close(); ;)
Along that line I'm thinking of a post with no content and a bit in the post loop that says "if post_ID == NN then include this page instead of all the other stuff you normally do".
We have a [url=http://www.waffleson.co.uk/2006/11/29/playing_with_custom_pages]plugin[/url] that allows you to do that ;)
Now I know I probably could get away with putting the javascript back into the specific page, which would reduce my total number of files and simplify my skin,
and a plugin that allows you to do that ;).... once Scotts finished the writeup :|
¥
9 balupton May 06, 2007 16:33
¥åßßå wrote:
Next I need to figure out why my popup for powerball numbers launches a new tab and never finishes loading even though it's done filling up with numbers.
I've not looked at your script, but if you do something like document.write(); you also need to document.close(); ;)
¥
What's this document.close() black magic you speak of?
Oh and EdB, you are definitly better off using a switch statement than such a horrible if ladder.
10 yabba May 06, 2007 16:36
11 edb May 06, 2007 16:54
Yeah I know on the switch thing. Just threw down a quick little "will it blend" type of thing. An if is good. Two ifs is not the worst thing in the world. Three ifs, especially three ifs you know will become 5 ifs, is crap that needs to be a switch. I read that on the wall of a stall in a mens room in a bus station in a small town, so it's pretty much fact. And now it's done. Better test it, but it's done - and my hacks NEVER fail ;)
Yabba I recall reading about your abusive treatment of the linkblog. We should make a deal regarding your "plugin that wishes it would ever see the light of day" and my plugin that I begged stk to adopt so's I wouldn't have to face it's guts and therefore be intimidated by what I unleashed on the world. Again. MINE comes with actual users, so you're getting the bargain end of the deal.
balupton if I could help you with licensing issues I would try, but I'm an idiot on that stuff. One thing I can help you with is black magic. If you open a document you can use black magic to close it. In other words, thanks Y: that fixed the problem of it not realizing it was done loading.
12 yabba May 06, 2007 17:21
"Pass the buck" EdB wrote:
MINE comes with actual users, so you're getting the bargain end of the deal.
lol, thanks :p
Good to know that the black magic worked huh, saves me having to slaughter another virgin or summat :D
¥
13 john May 07, 2007 09:24
EdB
Nice way to target javascripts to specific pages...
14 john May 09, 2007 03:47
Re topic
I use <body onload="myajax = new isiAJAX();"> for a xhtml strict ajax gallery page and it sails through validation.
You should probably wait for someone who knows, but I have used "onload" commands to initiate javascript in the body section of webpages. They were already coded scripts and I was just following instructions included with them.
Oh, and I don't think it wasw xhtml.