Log In    |    Knowledge Base    |    4D Home
Tech Tip: Getting URLs to work in web pages returned from 4DACTION calls
Published On: May 18, 2001

If you return a page to a web browser as the direct result of a 4DACTION call, you may find that the relative URLs in your HTML page are not handled properly. For example, you have a link in your default home page as follows:

<a href="/4DACTION/SendPage2">Click to send page 2.</a>

In the 4D Project Method "SendPage2" you have the following code:

SEND HTML FILE("page2.html")

And the contents of the file "page2.html" are:

<head><title>Page 2</title></head>
<img src="picture.gif">

When the page "page2.html" is sent to the browser, the image file will not show up properly. If you check the properties of this image you will see the browser is actually requesting "". This is not a problem with 4D, it is the way web browsers are designed to work - they automatically add the base URL of the requested document in front of all relative URLs contained within it. To correct this behavior you have several options:

1) Refer to the root of your site by adding a forward-slash in front of your URLs. This way the URLs will only get the host name placed in front of them by the browser and not the "4DACTION/" part. For example,

<img src="/picture.gif">

2) Use absolute links instead of relative ones in your URLs. For example,

<img src=""><

3) Place a BASE tag in the HEAD section of your HTML document to explicitly specify the base path of the document, which will apply to ALL relative links in the page. This will override the location from which the document was requested. For example,

<base href="">