Jump to content

help resizing an image


dzhax

Recommended Posts

Trying to generate some money to help pay for costs of a site. So i am using a service to add some ad banners to my page. The problem is none of the ads fit my current layout they are either not wide enough or too wide. I need to find a way to limit the width and at the same time expand images that are not wide enough.This is all the site gives me to add into my site.

<script type='text/javascript' LANGUAGE='javascript' src='http://www.qksz.net/1e-jn20'></SCRIPT>

I have this code in one of my divs. If the banner is too big it aligns right with the div and explodes off the left hand side of the layout and the same with the small ones but it leaves an ugly blank space on the left.Centering the image will not be an issue its just making it fit in the div as good as possible.For now its just in a regular div that is taking "orders" from its parent so i can add anything i need to to the divs style etc if needed.For the purpose of getting this to work lets say the div is 200px wide (height is not an issue)there are 2 rotating images in the banner listed above the first one is 300px wide and the second is only 120px.

Link to comment
Share on other sites

using the container id reference you could target these images using js to change the width, but you need to change these after the banner images have loaded. It all depends how they displayed, are they set to 100% width to fit generated fix size div container, or a fixed size themselves only.If you can supply link, that would help.

Link to comment
Share on other sites

They are just images with the widths of 300 and 120px. I have no idea what the javascript does the above code is all i have and i just put it into a

<div style="width:200px;">	 <script type='text/javascript' LANGUAGE='javascript' src='http://www.qksz.net/1e-jn20'></SCRIPT></div>

Link to comment
Share on other sites

This tiny block of code has three errors I can see. Firstly, it contains the "language" attribute, which is deprecated. Secondly, the src path does not lead to a .js file (which, I think is required...correct me if I'm wrong), and lastly the closing tag is in uppercase, which is not recommended.

Link to comment
Share on other sites

In FireFox right click page and select all, now right click again and select view selection source, you will be provided with the source that this javascript file has created, make copy of generated code and post.OR as experimentgive div container id

<div id="adcontainer" style="width:200px;">	  <script type='text/javascript' LANGUAGE='javascript' src='http://www.qksz.net/1e-jn20'></SCRIPT> </div>

option(1) css

 <style type="text/css">#adcontainer img {width:200px !important;} </style>

this is unlikely to work if image is given width value already.option(2)insert below code in between <head></head>

 <script type="text/javascript"> /*<![CDATA[*//*---->*/  window.onload=function(){ var idcon = document.getElementById("adcontainer"); var adimg = idcon.getElementsbyTagName("img"); adimg[0].style.width="200px"; } /*--*//*]]>*/ </script>

Link to comment
Share on other sites

This tiny block of code has three errors I can see. Firstly, it contains the "language" attribute, which is deprecated. Secondly, the src path does not lead to a .js file (which, I think is required...correct me if I'm wrong), and lastly the closing tag is in uppercase, which is not recommended.
each of the 3 errors are understandable. that is exact code the site tells me to copy and paste into my page. thats why i just copy and pasted it. as far as the source goes not linking directly to a js file, thats most likely because the site i am getting the ads from generates the picture randomly and uses js to print.and @dsonesukIll take a look at that. looks promising thanksanyone care to explain what /*<![CDATA[*//*---->*/ does isnt that just commented out code????
Link to comment
Share on other sites

It basically prevents older and newer XML compliant browsers, reading js as html, this comment tag, as some can't wait to mention, is a bit over the top, but originally it covered usage by older browser, which is not required now. But!, it works still, and still validates, and as for you guys who can't get over that i still use this, GGAFL.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...