Jump to content

GuitarNinja2008

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by GuitarNinja2008

  1. Oh, ok. Thank you guys for the input. I tried to set the src with the line: i2.src = i.src. To me this should make sense, as i2.src is what I am trying to give a value to and i.src is the value I am using. So I tried to use the assignment operator the same way you would when assigning a value to a variable. What would be a better way to set the src then? EDIT: Or are you saying that I am approaching it correctly but I simply put the "i2.src = i.src" code in the wrong place?
  2. Hey guys! So, what I am trying to do is make a function that can be called when the user clicks an image, which will 1) find the original natural height of the image clicked, 2) open a new window containing the image at its natural size, and 3) neatly scale the size of the window to fit the size of the image. I have gotten the effect to work for one image at a time, but only by manually plugging in that specific image's width/height into the window.open() command. I want something that will work for any image regardless of it's dimensions, this way I can use the same function for multiple images. I admit I am very new to javascript and have been stuck on this same function for a few days. I have read lots of articles, but I still can't get it to work. My current approach is going off of advice I found here: http://stackoverflow.com/questions/8579391/getting-the-original-size-of-a-scaled-image. What I gathered is that somehow you have to create another copy of the image in your cache, so it does not get confused by css styling that changes the size, and then get the width/height from that. It seems you do that by using Image() and setting its .src property to the .src of the original image. Then I think you assign the .height/.width properties of that cached copy to variables and those should have your values. But to do that you have to use .onload somewhere to make sure that the image is loaded first. That said, here is my code so far: HTML: <img class="imageActive" src="Thirty-six Views of Mount Fuji - No. 14 (copy).jpg" onclick="openWindow()" alt="Mount Fuji, Japan" /> JS: <script type="text/javascript"> function openWindow() { var i = document.getElementsByClassName("imageActive"); var i2 = new Image(); i2.onload = function() { var xImage = i2["width"]; var yImage = i2["height"]; i2.src = i.src; window.open("Thirty-six Views of Mount Fuji - No. 14 (copy).jpg", "Mount Fuji","height=yImage, width=xImage, left=60, top=20"); }; }; </script> When the user clicks the image, it is supposed to call the openWindow() function I created and that is supposed to open the new window. However, when I test this in my browser nothing happens. I have tried changing the code slightly but again either nothing happens or a new window does open but it is too small. Any help with this is sincerely appreciated. It's been driving me nuts. lol
  3. Cool. I had attempted to learn C++ before, but for somebody like me with no experience it was kind of daunting. I found HTML and CSS easier, even if just because you don't have to worry about the hassle of linking/compiling your program just to be able to see if your code works or not. And JS seems to be at least more approachable for a newbie because you can use it in your HTML for even simple little stuff that doesn't require a lot of code. I mean, it's not like your whole website has to be in JS... lol. I don't really know all that much about Java, but I did get the impression that it was the thing to use if you wanted to make something that was compatible with different types of devices.
  4. Cool, thanks. I didn't know about notepad++, but that's quite a good find. I went to wampserver and it was all in spanish. Is there another site that's in english? I Still can't tell exactly what it was about. I'm guessing you can use it to put your website on the internet?
  5. Hi everyone. My name is Corey, and I'm just looking for a bit of advice. I'm 22 now and definitely feel the need to start building some sort of career. But, because of a very stupid but serious injury to my leg a few years ago, it's a bit difficult for me to be physically active for long periods of time. So, I was trying to think of something neat to do that wouldn't be very physically demanding and two things popped into my head: computer programming or web design. I already have an interest in computers, and I've been reading articles on HTML and CSS and playing around with a bit of code. It's fun in a sort of logical yet creative way and I definitely want to explore it as a possible career path. I'm trying to put everything in perspective first, so I'm really curious about what you need to know in order to pass for a decent web developer. Like, to the point where you could expect get hired as one. I know the three big things at first seem to be HTML, CSS and JavaScript, but what comes after that? I know in the end it probably comes down to getting a college degree and practical experience, but I was hoping to feel everything out a bit before jumping off the deep end and paying tuition. Is there a better way for me to get started then just jumping from article to article on the internet and testing code in my computer's notepad? And for practical experience, what can I do to get exposure aside from college? Thanks for any help.
×
×
  • Create New...