Everything posted by moxie
-
An efficient way to code this in JS?
This example could probably be adapted for your needs: var sections = 8; //number of sections var sectionSize = 360/sections; //degrees in each section var direction = Math.random()*360; //a random direction for(i=1; i<=sections; i++){ //is the direction within an area? if ( direction > (i-1)*sectionSize && direction < i*sectionSize ) { alert('directon:'+direction+' is in section:'+i); break; } } Hope it helps
-
Outputting File Size
I think this would have to be done from a server level. If you're trying to calculate the bandwidth based on an already rendered page, the results would be inconclusive as if external elements like images and scripts are cached then they won't be downloaded from the server.
-
PHP/ajax file download
Looks like the header for Content-Disposition is slightly wrong: try changing from: header('Content-Disposition: attachment; filename='.$path.$filename); to: header('Content-Disposition: attachment; filename="'.$path.$filename.'"');
-
Relocating a div with JS
If I was to do this I'd probably have an additional destination div and get the IDs of the elements you want rearranged put into an array. You can then sort based on name (you'd have to use a naming convention which can be sorted correctly, eg div1, div2, etc) and this could be done dynamically if they're placed in a wrapping div and you get the IDs of the wrapper's children. I'd loop through the array of IDs and append the destination div with the contents of the div to be moved, followed by removing the original element. It's not exactly an elegant solution but theoretically it should work. Hope that helps
- What is this method called
-
Changing HTML tag attribute with JS
Hi there, I think the problem is to do with the use of innerHTML which will expect a string to be passed. innerHTML will essentially inject an html string into the selected element: // Example document.getElementById("html").innerHTML = '<div id="test"></div>'; I haven't tested this but I'd say that the innerHTML in your script would cause an error which could result in nothing happening in your page. You may also need to change the setAttribute piece too: //from: $(":first").setAttribute(" style='overflow-x:hidden'"); //to $(":first").style="overflow-x:hidden"; I'm not 100% on this one though, my javascript is a little rusty. I hope this helps.
-
Hey there
Hey everyone, I'm new I'd say I'm more developer than designer these days, mainly working in PHP but I originally studied creative multimedia & specialised in Flash. Hopefully I'll be able to catch the design bug again & help some others out along the way.