Duncman Posted July 12, 2007 Share Posted July 12, 2007 All right, so I want to make a Firefox extension and so far I've got it all sorted. Apart from the javascript part that is. What I'm trying to do is re-create the Safari image viewing ways when you open just a image file. When you open a picture, or click on a link that is just a picture, it displays the image without any spacing on the top and left sides, and is always full size. Here is an example (click to see the full size). <a href="http://www.mystdesigns.co.uk/uploads/Picture%201.jpg"><img src="http://www.mystdesigns.co.uk/uploads/Picture%201.jpg" width="500px" height"300px"></a> As you can see there is no margin above or to the left of the picture, and is zoomed in regardless of the window size. Is there any chance someone could create this for me? Or guide me through making it as I really should learn javascript. The zoom problem doesnt need to be sorted. I'm not too fussed about that, but any help in creating the anti-gap code would be much appreciated. As far as I can see, it would entail getting the URL, checking to see if it ended in JPG or GIF or whatever (I'd assume applying it to all images rather than seeing if the URL finished with JPG would mean all the images on a page would be moved) and then applying a CSS rule to give it negative margins and shifting the image up. Any help would be much appreciated. Quote Link to comment Share on other sites More sharing options...
Duncman Posted July 12, 2007 Author Share Posted July 12, 2007 ok, so after having a go at this myself for a little while, ive so far got this. var is_input = document.URL.indexOf('.jpg'); if (is_input != -1) { addr_str = document.URL.substring(is_input+1); } if (addr_str == 'jpg') { document.write ("<style>body {margin:0px}</style>"); } else { } As far as I can tell from this code, its looking in the URL for .jpg, then something is going on next, then if that addr_str is equal to jpg, it should set the page margins to 0, else it does nothing. Now theres 2 problems with this. When testing this, the error console in Firefox said that the first line is invalid somehow, or there was some problem with it. The second problem is that I'm trying to apply a style to HTML, where HTML wouldnt be displayed. Does anyone know how to get it to set the margins on an image to 0? Quote Link to comment Share on other sites More sharing options...
mainewoods Posted July 15, 2007 Share Posted July 15, 2007 you can do this: <script> document.getElementById('idInPictureTag').style.margin =0; document.getElementById('idInPictureTag').style.padding =0; //you might also have to do document.getElementById('idInPictureTag').vspace =0; document.getElementById('idInPictureTag').hspace =0; </script> Quote Link to comment Share on other sites More sharing options...
Duncman Posted July 15, 2007 Author Share Posted July 15, 2007 Nope, no luck with that code either. Looks like a little more thought will have to go into this extension. Thanks for trying anyway Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.