Forums / Developer / Resolution check

Resolution check

Author Message

Pål Messenlien

Thursday 18 January 2007 3:13:10 pm

Im trying to remove a flash from our mainpage if the resolution is lower than 800x600

<script type="text/javascript" language="javascript">
<!--
	var width = screen.width
	var height = screen.height
	if (width > 800)
		document.write("{def $visflash = yes}");
	else {ldelim}
		document.write("&nbsp;Your screen resolution is set to "+width+ "x" +height+".  This site is best when viewed at 800x600 or greater.</B><BR>");
	{rdelim}
//-->
</script>

And this is what i use to check and show the flash

{if is_set( $visflash )}
   {let flash=fetch(content,node,hash(node_id,5863))}
			{node_view_gui view=full content_node=$flash}
		{/let}
{else}
    It is not set.
{/if}

The check returns right, but still $visflash returns true.

--------------------------------------------
Høgskolen i Lillehammer
Lillehammer University College
http://www.hil.no
--------------------------------------------
Messenlien IT
http://messenlien.com
-------------------------------------------

kracker (the)

Thursday 18 January 2007 4:21:32 pm

I would modify your direction to include,
a javascript check which shows the user
and offers a choice / solution.

Perhaps exposes a url or does a redirirection
to eZ and setts a session variable or something ....

You want to pass a variable back to eZ (in
one of many ways possible). Which
returns to the user the modifed, view
as needed?

Because trying to set a template variable
at the end of each requqest via javascript,
yet evaluate the variable during the start
of each request which just simply won't
work.

Instead use a variable which can
be passed from javascript to eZ publish,
perhaps using a url argument.

hth,
//kracker

it makes sense from a certain point of view.

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Bruce Morrison

Thursday 18 January 2007 5:38:59 pm

Hi Pål

The reason you code is not producing the desired result is that the javascript is generating eZ template code.

The basic order of the process is:

1. User results URL
2. eZ does it's magic and generates html from combining the content and 3. templates.
4. HTML is read by browser
5. Any javascript is run in the browser

Your code will just write the text template code into the HTML in the users browser. It's not happening in the right place in the process.

Some suggestions:
+ Display the flash for all users but use javascript to hide (via CSS) or remove the flash from the HTML if the screen width < 800

+ If the screen width > 800 use AJAX to retrieve the code for the banner and add it in the HTML using javascript.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Pål Messenlien

Friday 19 January 2007 12:27:56 pm

Thanks alot guys.
I see now i need to get me some better basic javascript knowledge. Been stealing code to long:)

The flash mentioned here is something thats being placed on the frontpage of our website. The reason i want remove it is cause it breaks the design in lower resolutions. Damn marketing people! Making a redirection url or refresh of page with a variable would work, but its not something that looks good. I prefer the user with lower resolution to not see the flash at all since it dont have any other function than being fancy. Hiding it with css would work, but then the user downloads 200k of something he cant see, and the flash would be visible when removing styles on the page.

The ajax solution sounds like something that would work, but i dont have enough knowledge about ajax todo it.

I came up with another solution after some googling:
http://www.zimmertech.com/tutorials/javascript/21/page-resolution-detector-tutorial.php

Could i use a cookie instead maybe?.. I have tought a litle about making the site resolution dependent, not only the layout and design, but maybe move some ez items around.

Will dig into what i have for now, but more suggestions (and example code) are welcome:)

--------------------------------------------
Høgskolen i Lillehammer
Lillehammer University College
http://www.hil.no
--------------------------------------------
Messenlien IT
http://messenlien.com
-------------------------------------------

Nicolas Lescure

Saturday 20 January 2007 5:29:40 am

Hi.

You know, noone use resolution under 800*600 today... Even 800*600 is not very used.
If you don't want the flash without CSS, you can try a javascript that remove the flash object when the page is loaded.
But ok, they have downloaded it... it is not really a problem for 0.1% (maybe) of users.

Pål Messenlien

Saturday 20 January 2007 3:54:48 pm

We have 1% users using 800x600 or lower on the webpage. During a month thats about 1000 users. These users are often blind and reading the page with a special software or other equipment. The goal is to make the webpage accesible to these also. I think the css removal should do the trick untill i find something better.

--------------------------------------------
Høgskolen i Lillehammer
Lillehammer University College
http://www.hil.no
--------------------------------------------
Messenlien IT
http://messenlien.com
-------------------------------------------