0

I'm new to Dojo for a couple of months and just come across some difficulties with dojo iframe. What I am trying to do now is to create an iframe element using dojo/request/iframe and load a <div> element from remote url, but what I found from the web page is pretty complex, that I don't know how to grab it. I've tried the following code:

iframeRequest.post(url, {handleAs: 'html'}).then(function(response) {
    response.querySelector('div[id=idx_layout_BorderContainer_5]')
})

But it doesn't work, and specifying the element id seems not precise enough to load what I need as I noticed that the target element id changes every time when I load the page.

So I'am asking the below questions:

  1. How am I able to locate the correct element from a remote webpage?
  2. Is the syntax used to load the content correct?

Really appreciated for your help!

EDIT: To be clear I actually came across the following questions to look for a workaround:

How do I crop the contents of an Iframe to show a part of a page?

But the solution looks pretty dumb and that is immune to some browser events. Any ideas?

Issac Ng
  • 13
  • 4
  • Decompose your problem into small trackable and runnable issues and share it here, as instructed: https://stackoverflow.com/help/mcve. Does dynamic content load works for you as in [dojo example](http://dojotoolkit.org/reference-guide/1.10/dojo/request/iframe.html#examples) when having static target? Dealing with dynamic div id is a different problem, right? – andy Jan 24 '18 at 09:23
  • Take a look here https://stackoverflow.com/questions/3272071/iframe-to-only-show-a-certain-part-of-the-page and here http://www.dimpost.com/2012/12/iframe-how-to-display-specific-part-of.html – soeik Jan 24 '18 at 16:44
  • Thanks @andy and @Kirill! Am now using the work around of setting the margin to a -ve number so that the page content of the iframe is cropped. But I am still curious on the method of picking the right `div` from the remote content. @andy I was trying to set a debugger and see what is happening after the request. However I can't step over properly as the response was overwritten by other GET request after the breakpoint was triggered... – Issac Ng Jan 26 '18 at 02:38

0 Answers0