-
Web address conversion help...
Hi,
I need to be able to call an image from another website. The script I'm using will only work if the images are on my own server and called with a relative address.
example:
<PARAM name="image1" value="image1.jpg">
I need to be able to call the image from an absolute address.
example:
<PARAM name="image1" value="http://anotherwebsite.com/image1.jpg">
Can someone please show me a way to do this. Do I need to use a variable or an other type of code so that my script will work with an absoloute address value.
Thanks,
John
-
Perhaps if you showed us your code that deals with those parameters then someone might be able to help.
My guess is that you're using a File instead of an URL in your code somewhere.
-
Here's that part of the code:
--------------------------------------------
{
_5 = getImage(getDocumentBase(), "on.gif");
_4(_5);
_2.drawImage(_5, _8.width - 18, _8.height - 32, this);
}
--------------------------------------------
{
_5 = getImage(getDocumentBase(), "off.gif");
_4(_5);
_2.drawImage(_5, _8.width - 18, _8.height - 32, this);
}
--------------------------------------------
{
g.setColor(new Color(_71));
g.fillRect(0, 0, _8.width, _8.height);
g.setColor(new Color(_72));
String s1 = "Loading Image " + Integer.toString(i + 1);
g.drawString(s1, _9 - fontmetrics.stringWidth(s1) / 2, _10);
update(_1);
if(getParameter("image" + Integer.toString(i)) != null)
{
_5 = getImage(getDocumentBase(), getParameter("image" + Integer.toString(i)));
_4(_5);
_5 = _2(_5, _75, _75);
System.arraycopy(_20, 0, _81, i * _75 * _75, _75 * _75);
}
--------------------------------------------
Thanks, John
-
You see, getDocumentBase() returns the location of the applet.
All you really have to do is replace getDocumentBase()with new URL("http://blah/") or whatever your base is.
ie:
getImage(getDocumentBase(), getParameter("image" + Integer.toString(i)));
becomes
getImage(new URL("http://blah.com/"), getParameter("image" + Integer.toString(i)));
or if you want the parameter to contain the entire location you would use the getImage(URL) method as opposed to getImage(URL, String).
Hope that makes sense.
-
Hi Drain,
Thanks for the reply, it was very helpfull, but when
I change the code from:
_5 = getImage(getDocumentBase(), getParameter("image" + Integer.toString(i)));
To:
_5 = getImage(URL url), getParameter("image" + integer.toString(i)));
I get 1 error saying ')' expected.
What do I need to change to get this to work.
The value for "image" must be able to have the full address for any image ex. "http://www.anysite.com/image1.jpg" inserted into the HTML file.
Thaks in advance,
John
-
Read the first part of my post again. The bolded part, specifically.
When I said getImage(URL) I didn't mean it as literal code, just that you can use the getImage method that takes a single parameter (an URL).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks