is there a way to get the URL where is the revlet ?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
dme69
Posts: 22
Joined: Sat Nov 14, 2009 5:57 pm

is there a way to get the URL where is the revlet ?

Post by dme69 » Thu Nov 19, 2009 5:52 pm

Hello all,

I want to load some text files in a revlet to populate some menus. This files will allways be at the same place as the revlet.
I know it's possible to find the path to stack inside the IDE but how to do it for the web ?
I'm not sure I'm clear.

I hope someone will understand what I mean and I promise to make some efforts to speak a better english ;-)

Thanks.
Dominique.

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Re: is there a way to get the URL where is the revlet ?

Post by SparkOut » Thu Nov 19, 2009 8:33 pm

Yes it's possible but you have to use the fully qualified URL.
dme69 wrote:This files will allways be at the same place as the revlet.
is perfectly understandable, but at the risk of being accused of being deliberately awkward, it's not, strictly speaking, the actual case.
The files are in the same place as the place (the url) from which the revlet is being served. The actual presence of the revlet is running in the browser on the client's computer so to refer to a local path relative to the revlet you are talking about somewhere on the client side. To get the revlet to refer to the location of the text file on the server, you need to use the fully qualified domain url (eg http://www.mydomain.com/myfiles/myfile.txt). That may result in permission issues, etc. so be careful.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Nov 20, 2009 3:41 pm

Hi Dominique,

There are so many ways to do this. If you don't want to include a static URL in your scripts, you might include the URL in the embedding HTML code and get the data from the revletParams property/array.

Example:

Code: Select all

<!-- Embed your revlets using code like this, to automatically guide the user to install the plugin, if it is not already installed -->
<div id="plugin" style="display:none">
<object classid="CLSID:BHJ9JHB-BHJM-87R1-NHB7-MNBG53AJ9B" width=330 height=219>
	<param name="src" value="MyRevlet.revlet"/>
	<param name="stack" value="Untitled 1"/>
	<param name="requestedName" value=""/>
	<param name="instanceID" value=""/>
	<embed type="application/x-revolution"
		src="MyRevlet.revlet"
		width=200 height=200
		stack="Untitled 1"
		requestedName=""
		instanceID=""
		locationUrl="http://www.domain.com/path/"
	></embed>
</object>
</div>
<div id="noplugin" style="display:none">
	<a href="http://revweb.runrev.com"><img src="http://www.runrev.com/revweb/images/revweb-noplugin.gif" border=0></a>
</div>
<!-- Revlet embedding code finishes above this line -->
I have added

Code: Select all

		locationUrl="http://www.domain.com/path/"
manually. You can obtain the data in the following way:

Code: Select all

put the revletParams into myArray
put myArray["locationUrl"] into myUrl
You might use javascript to write the locationUrl dynamically. For example:

Code: Select all

document.write(location.href);
and you might even do this inside your revlet:

Code: Select all

do "document.location.href;" in browser
put the result into myUrl
Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

dme69
Posts: 22
Joined: Sat Nov 14, 2009 5:57 pm

Re: is there a way to get the URL where is the revlet ?

Post by dme69 » Mon Nov 23, 2009 2:24 pm

Thank you very much for your precious help.

Dominique.

Post Reply