Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

JS/DOM Question

  • 21-09-2005 3:35pm
    #1
    Registered Users, Registered Users 2 Posts: 55,571 ✭✭✭✭


    Hi all,

    I'm trying to adapt a function that calculates the size of images on a webpage. The function is as follows:
    function calculate()
    {
    	if (!document.fileSize)
    	{
    		alert('This script does not work in your browser.');
    		return;
    	}
    	var size = (document.fileSize)*1;
    	var y = document.images;
    	var imglength = 0;
    	for (i=0;i<y.length;i++)
    	{
    		imglength += (y[i].fileSize)*1;
    	}
    	var total = size + imglength;
    	var writestring = 'File size HTML: ' + size;
    	writestring += '\nFile size images: ' + imglength;
    	writestring += '\nTotal file size: ' + total;
    	if (total > 40000) writestring += "\nFile too large!";
    	alert(writestring);
    }
    
    What I'm trying to do is pass a URL as a parameter instead of just using the current page. I'm not a DOM expert, so I'm not sure if its possible using 'document.whatever'. Any suggestions? Intended usage would be:

    calculate('http://www.google.ie/index.html')

    Is it possible? Thanks in advance...


Comments

  • Registered Users, Registered Users 2 Posts: 55,571 ✭✭✭✭Mr E


    Actually in hindsight, I don't think it can be done like this. The page will still need to be physically loaded for this function to work. I'll figure out a different way of doing it. Cheers.....


  • Registered Users, Registered Users 2 Posts: 1,268 ✭✭✭hostyle


    Javascript use of the DOM as you have figured out is client side only :) Most server side languages are well able to do this sort of thing - PHP in particular is probably well suited for this exact thing.


Advertisement