HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Determining width of main screen

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#5699 (In Topic #1370)
Avatar

Fan in training

Determining width of main screen

Does anyone have a way of determining the width of the main screen, either via .php code at run time, or though java script via a .tpl at render time?

The code that I am working on for the scrolling marquee must have the width defined and I would like to be able to make it non-static so that no matter what resolution someone views the pages at, it appears normal.

Thanks,
James

Back to the top
 
Posted
Rating:
#5710
Avatar

Community saint

You could try placing it within an IFRAME and use percentages within the parameters of the IFRAME.  

What code do you have so far for the scrolling marquee?
Back to the top
 
Posted
Rating:
#5712
Avatar

Fan in training

lol….  Not much.  I found some scraps of java code flying around on the internet and I am trying to port it over for ocPortal.  I want to be able to database the entries for my own use (i.e. Run this from today to Dec 10 and that from dec 2 to jan 5).

However, when it set's up the java code for the marquee it defines the width as something like width = 300px.  I am not sure if I can use a %.  I'll mess around with it.

I am trying to get these simple things added as I want my employer to go to ocPortal for the main website.  I get so tired of people complaining that it never gets updated….  blah blah blah.  I need the marquee (which BTW: there is a <marquee> tag that works nativly with IE and Netscape now), this java one is cross platform.  Since my company uses IE mostly I could probably get away with hard coding my own, but I feel since I am not paying for ocPortal (yet) I need to contribute.

A few other things I need to get down is a lunch calendar that has built in ocPortal support (I saw in a forum earlier).  So that will probably be my next project, but a simplistic calendar (Mon = Lunch-Corn Dog, juice, milk).

If you want the code that I have for the Java Marquee I can send it to you….

OK, now I have babbled on for a bit, back to work.

Thanks,
James

Back to the top
 
Posted
Rating:
#5715
Avatar

Well-settled

I use this code within HEADER.tpl in the <head> section to call one of two CSS files depending on screen width, but I don;t know how useful or relevant this might be for you:

Code

<script language="javascript" type="text/javascript">
if (screen.width < 800) {
document.write('<link href="/css/sc.css" rel="stylesheet" type="text/css" />');
} else {
document.write('<link href="/css/sc2.css" rel="stylesheet" type="text/css" />');
}
</script>

Rather than trying to define a width through some tricky javascript all over your page, you could try setting the width as a percentage like you mentioned. I don't see why you wouldn't be able to. You can do it with text boxes and all sorts ;)

If it doesn't like percentages you could try using somehting like the above bit of javascript in the middle of your javascript marquee code to cover the main screen resolutions from 800*600 upward (1024*768, 1280*whatever and so on).

Hope that helps some ;)

 The Last Outpost - Entertainment news, reviews, previews & interviews. No holds barred - big boys' language in use!

Back to the top
 
Posted
Rating:
#5737
Avatar

Fan in training

Thanks Pete.  That would probably do it also.  I could make the width one value when the sreen res is 800x600 or lower and another when it is higher.

My wife and kids have been sick this week, so I have not had a chance to work on it just yet.  I hope to get some time on this weekend.

Thanks,
James

Back to the top
 
Posted
Rating:
#5797
Avatar

Is it possible to give your width a percentage so that the browser resizes the marquee according to the size of the window?

Back to the top
 
Posted
Rating:
#5809
Avatar

Fan in training

Possibly, one of the scripts I was working on can take a %, but a few of the others can't.

I like the features that some of the Java ones have, but I might just wimp out and use the IE <marquee> tag and forget about it.  The only thing that I would have to do then is modify the database to automaticly add and remove messages.

Thanks,
James

Back to the top
 
Posted
Rating:
#5829
Avatar

Well-settled

If you're stuck for javascripts that might do this then I'd suggest looking at the Javascript script section of hotscripts.com - there should be a fair few to try out before using teh dreaded marquee code ;)

 The Last Outpost - Entertainment news, reviews, previews & interviews. No holds barred - big boys' language in use!

Back to the top
 
Posted
Rating:
#5831
Avatar

Fan in training

WHY DIDN't I THINK OF THAT!!!!!  I use hostscripts for all kinds of php ideas and codeing expamples.  I didn't even consider it.  Thanks for the tip!

(I belive a duh to myself is in order)

Thanks,
James

Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: