Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread TPage question
Sun, Jan 27 2013 9:36 AMPermanent Link

Uli Becker

Hi,

in order to get the title of a website that I launch in a TPage control,
I want to read the HTML of the site:

<code>

  Memo1.lines.text := page1.documenttext;

</code>

I get this error:

Uncaught TypeError: Cannot read property 'documentElement' of null

In the js-file the error occurs here:

<code>
webctrls_tpage.$p.tpage_getdocumenttext = function()
{
   var $t = this, $r;
   if ($t.tpage_floaded)
      $r = $t.tpage_fframe.contentDocument.documentElement.innerHTML;
<------------
   else
      $r = "";
   return $r;
};
</code>

Any idea?

Thanks Uli

Sun, Jan 27 2013 4:47 PMPermanent Link

Uli Becker

Obviously I am not allowed to do so because of SOP. Frown

Mon, Jan 28 2013 3:46 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< Obviously I am not allowed to do so because of SOP. Frown>>

Yep, security restriction. Frown

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Jan 29 2013 3:06 AMPermanent Link

Uli Becker

Tim,

> Yep, security restriction. Frown

OK, I see.

So there is no way to get the current URL from a TPage control when the
user navigates to another webiste within the frame?

How does TinyURL do it?

They use a script like this:

javascript:void(location.href='http://tinyurl.com/create.php?url='+encodeURIComponent(location.href))

Sorry, if I ask silly questions: I am not that good in web-programming. Smile

Thanks Uli
Fri, Feb 1 2013 4:53 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< So there is no way to get the current URL from a TPage control when the
user navigates to another webiste within the frame? >>

There is (WebDOM - THTMLFrameElement.src), but I'll have to add it to the
TPage.

If you have any other questions, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com
Sat, Feb 2 2013 4:34 AMPermanent Link

Uli Becker

Tim,

> There is (WebDOM - THTMLFrameElement.src), but I'll have to add it to
> the TPage.

That would be really great. Please add it... Smiley

Regards Uli
Sun, Feb 3 2013 1:01 PMPermanent Link

Uli Becker

Tim,

> There is (WebDOM - THTMLFrameElement.src), but I'll have to add it to
> the TPage.

I changed WebCtrls like this:

<code>

TPage = class(TControl)
      private
      ...
         FSource: String;
         function GetSource: String;
     public
     ...
     property Source: String read GetSource;

function TPage.GetSource: String;
begin
  result := FFrame.src;
end;

</code>

But FFrame.src returns the same as TPage.URL - if I navigate to another
URL within the frame, FSource doesn't change.

Actually it doesn't seem to be possible at all to get the current URL of
a frame because of the SOP.

Regards Uli
Mon, Feb 4 2013 11:43 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< But FFrame.src returns the same as TPage.URL - if I navigate to another
URL within the frame, FSource doesn't change. >>

Are you looking at in in the OnLoad event or later ?

<< Actually it doesn't seem to be possible at all to get the current URL of
a frame because of the SOP. >>

It's always possible - it's completely up to the browser vendor/org to
determine how they want things to work.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Feb 11 2013 5:42 PMPermanent Link

Uli Becker

Tim,

> Are you looking at in in the OnLoad event or later ?

I tried both. The URL is always the same.

Uli
Tue, May 28 2013 11:57 AMPermanent Link

Matthew Jones

Did this ever get resolved? I really need this too, for a much better user
experience. I can see that the Chrome iFrame has a #properties element, and that
knows the URL. Happy to hack it is appropriate, but my aim is to allow the user to
store the URLs they are at.

/Matthew Jones/
Page 1 of 2Next Page »
Jump to Page:  1 2
Image