The problem I was trying to resolve was taking HTML I did not write or
have any control over, and fixing up any URIs to the images so that
they were fully-formed, such that the resulting HTML code could be
embedded in a social networking site and still function. Code was
being added in either page-relative or root-relative form, but not
ever in absolute canonical URIs.
What I ended up doing was asking the browser to do it:
$('generate').observe('click',function(evt){
evt.stop();
$('ExportMe').select('img').each(function(img){
img.setAttribute('src',img.src);
});
var text = $('ExportMe').innerHTML.stripScripts();
$('TextBox').setValue('<div id="EmbedMe">' + text + '</div>');
$('TextBox').select();
});
This seems to do the trick for me, because at the moment I ask the
browser for the src, it has already combined it with the base and
figured out an absolute URI. When I use writeAttribute to write it
back into the DOM, that puts the absolute URI into the page, and then
the innerHTML is up to date with what the browser has already figured
out.
Walter
On Sep 28, 2010, at 11:43 PM, ncubica wrote:
Is not better to use an object inside of the Array. at least is more
readable
var uri = [ { base : "mypathbase/", img : "image1.png" },
{ base : "mypathbase/", img : "image2.png" }]
var img = uri[0].base + uri[0].img; // mypathbase/image1.png
best
On Sep 28, 2:24 pm, Walter Lee Davis <wa...@wdstudio.com> wrote:
Imagine two arrays:
[one, two, three, four]
[three, four, five, six]
And I want to end up with [one, two, three, four, five, six] but I
have no guarantee that there aren't some repeated values in there
-- I
can't just use Prototype's Array#uniq to do this -- because order of
elements is important. I need the equivalent of lining up two
transparencies on a light table, except with arrays.
That's a very simplified model, let me explain what they really
represent: The first is the base HREF of the page, and the second
is a
path to an image file. I need to construct an absolute URI to the
image, regardless of whether it was coded as a root-relative or page-
relative URL in the HTML.
Can anyone suggest a way to do this?
Thanks,
Walter
--
You received this message because you are subscribed to the Google
Groups "Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
.
To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com
.
For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en
.
--
You received this message because you are subscribed to the Google Groups "Prototype
& script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.