Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2004
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help a Newbie - Opening a Sized Window from Menu

    Hello everyone!

    I'm hoping someone out there will take pity on me as a person who is still learning javascript.

    I've been having trouble with the opening of a sized window from an MM_jumpMenu function lately...and I'm stumped. I'm using a little script that I've used successfully on other web sites I've helped to build:

    // JavaScript Document
    function sizedwindow(strURL,strType,strHeight,strWidth) {
    var strOptions="";
    if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
    if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
    if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
    window.open(strURL, 'newWin', strOptions);
    }
    The sized window opens properly. However, I get the nasty "404 not found" error when trying to call and display the photos in question. An example of the problem can be seen when clicking on the first photo of the first listing (Front of House from Street, 501 West Van Dusen) at the following web page: http://www.qrehomes.com/listings/residential.htm

    If anyone has any ideas what might be going wrong, OR are willing to suggest a better way for displaying sized windows for the display of photos, I would love to hear from you! I've been losing my mind over the past two days trying to resolve this problem, and am at a loss as to what can be done to fix things.

    Thanks in advance for your help!

    Derek Tonn

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    nothing looks wrong with the script, make sure that what you are passing to the script is valid.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    wait wiat, after a second closer look, i see what the problem is......


    when opening a window the options must be within quotes......
    you dont have it writing it withing quotes.

    this fixes that:

    Code:
    // JavaScript Document
    function sizedwindow(strURL,strType,strHeight,strWidth) {
    var strOptions="";
    if (strType=="console") strOptions="\"resizable,height="+strHeight+",width="+strWidth+"\"";
    if (strType=="fixed") strOptions="\"status,height="+strHeight+",width="+strWidth+"\"";
    if (strType=="elastic") strOptions="\"toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth+"\"";
    window.open(strURL, 'newWin', strOptions);
    }
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #4
    New Coder
    Join Date
    Feb 2004
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey Brandon....thanks for taking the time to have a look at my problem. I tried that new code for the sizedwindow.js file that you suggested, and I'm still getting the 404 error when trying to view the photo in a new sized window. The files are DEFINITELY there with the right path....assuming I can use ../ to shorten the path instead of the full URL in the link. The "shortcut" link was working though....until I started messing around with the sized new window this weekend.

    Ugh. I'm confused. I can always go back to a simple "new window" type of functionality, but it seems silly/cumbersome to open a large new window for lots of little 360x480 photos.....

    Any other ideas? Thanks for your time.

    Derek

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I wrote this a while back. Maybe you can make use of it
    test.html
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>
    <style type="text/css">
    a img {
    border:0;
    }
    </style>
    <script type="text/javascript">
    function makePhoto(url)
    {
    	var photowin = window.open('photo.html?img='+url,'win','scrollbars=0,status=0'); // opens new window passing query string to url
    	if(photowin && !photowin.closed) photowin.focus(); // brings focus to window if its still open
    	return false;
    }
    window.onload = function()
    {
    	var thelinks = document.getElementsByTagName('a'); // gets all anchors in document
    	for(var i = 0; i < thelinks.length; i++) // runs through the anchors
    	{
    		if(thelinks[i].getAttribute('rel') == 'preview') // checks to see if its rel attribute has a value of preview
    		{
    			thelinks[i].onclick = function() // if the above is true then assign an onclick to the link
    			{
    				return makePhoto(this.href); // this way users with js disabled will still see the images
    			}
    		}
    	}
    }
    </script>
    </head>
    <body>
    <div>
    <a href="images/img1.jpg" rel="preview"><img src="thumbs/tnimg1.jpg" width="150" height="150" alt=""></a><br>
    <a href="images/img2.jpg" rel="preview"><img src="thumbs/tnimg2.jpg" width="150" height="150" alt=""></a><br>
    <a href="images/img3.jpg" rel="preview"><img src="thumbs/tnimg3.jpg" width="150" height="150" alt=""></a><br>
    <a href="images/img4.jpg" rel="preview"><img src="thumbs/tnimg4.jpg" width="150" height="150" alt=""></a><br>
    <a href="images/img5.jpg" rel="preview"><img src="thumbs/tnimg5.jpg" width="150" height="150" alt=""></a><br>
    </div>
    </body>
    </html>
    photo.html
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="ImageToolbar" content="no">
    <title>&nbsp;</title>
    <style type="text/css">
    html, body {
    margin:0;
    padding:0;
    border:0;
    }
    </style>
    <script type="text/javascript">
    var imgname = location.search.split('='); // gets image filename
    var imgload = new Image(); // sets up preloading of new image
    imgload.src = imgname[1];
    document.title = 'Photos: ' + imgname[1]; // changes title to match image filename
    
    function readImage()
    {
    	var elem = document.getElementById('theimg');
    	elem.setAttribute('src',imgname[1]); // sets image src to proper image
    	var sw = (screen.width - elem.offsetWidth) / 2; // gets middle of screen horizontally
    	var sh = (screen.height - elem.offsetHeight) / 2; // gets middle of screen vertically
    	window.resizeTo(elem.offsetWidth,elem.offsetHeight); // resizes window to fit image dimensions
    	window.moveTo(sw,sh); // moves window to center of users monitor
    }
    window.onload = readImage; // starts the readImage function
    </script>
    </head>
    
    <body>
    <div><img src="#" id="theimg" alt=""></div>
    </body>
    </html>
    It passes an image name to the url as a query and its read by the popup window page.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •