View Full Version : Screen Size and output

10-23-2006, 08:14 PM
I have madea website, which is pretty unfortunate. I was originally messing around for about 2 days, and came up with a great layout. The bad side is that the background is 1030px. If screen width is greater than 1030 (1024) then it shows up as blank space. I came up with some javascript code based on the trusty google.com. I want:

If screen width is less than 1024, print <a href="JSmedia.php">Continue</a>
Else <a href="javascript:popUp('JSmedia.php')">Continue</a>

<script language='Javascript'>
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=0,width=1032,height="+ windowheight +",left = 125,top = 0,title=js');");
if (screen.width <=1024){

I don't know how to print/echo a link in javascript. the dashes represent the displayed links. That's where I am stuck.

10-24-2006, 12:29 PM
Are you asking how you would dynamically create an element?

function createAnchor() {
var anchor = document.createElement("a");
anchor.setAttribute("href", "JSmedia.php");
var text = document.createTextNode("Continue");
}The above code is what would go in the if statement. The getElementsByTagName("body")[0] line would change depending on where you want the anchor element to be inserted. In this case, itís inserted as the last child of the documentís first body element.

Oh yeah, as a side note, you should also use type="text/javascript" instead of the deprecated language="JavaScript".