Scrolling using JS in iframe

2,616 views
Skip to first unread message

Fernando Boucquez

unread,
Nov 8, 2015, 10:21:19 AM11/8/15
to atlassian-...@googlegroups.com
Hi people, dummy question. 

Does anybody know how to scroll (top for example) an AC iframe using javascript?


I don't have access to the parent frame due to cross-origin security.

window.scrollTo(x-coord, y-coord); does not work 

Maybe AP. provides scrolling somehow?

Cheers
Fernando

James Hazelwood

unread,
Nov 8, 2015, 6:08:00 PM11/8/15
to Atlassian Connect Dev
Hi Fernando,
Assuming it's the parent page that you want to scroll, there's no way to do this via the javascript API at the moment, I'm afraid. Feel free to raise an issue in the ACJS project though - it certainly sounds like something we could consider.

Regards,
James [Atlassian Connect]

Fernando Boucquez

unread,
Nov 10, 2015, 4:58:35 PM11/10/15
to atlassian-...@googlegroups.com
Hi James,

I'm actually trying to scroll the child page (my iframe). For some reason window.scrollTo(0,0) doesn't work when I call it with in my page inside JIRA but it does work when I call it as standalone page (no iframe)

Have anybody had the same problem?

Cheers
Fernando

--
You received this message because you are subscribed to the Google Groups "Atlassian Connect Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave Haden

unread,
Nov 10, 2015, 10:59:16 PM11/10/15
to Atlassian Connect Dev
Hey Fernando,

I just tried this with a "atlas-connect new -t jira project" by:
- limited the general page to 50px,
- manually scrolling to the bottom of the scrollable iframe, and
- using the console to call "window.scrollTo(0, 0)" inside the context of the iframe
and it worked :(

Where is the iframe that you are trying to manipulate?
What is triggering the call?
Is there anything else that could be related?

Thanks,
Dave
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connect-dev+unsub...@googlegroups.com.

Fernando Boucquez

unread,
Nov 11, 2015, 7:43:33 AM11/11/15
to atlassian-...@googlegroups.com
Hi Dave, thank you for showing me atlas-connect. Great improvement since I started AC over 2 years ago.

I'm extending your example:
  1. atlas-connect new hello-world (jira template doesn't exist with the default installation)
  2. npm install
  3. I've removed addon.authenticate() from index.js in order to open the page standalone bypassing security
  4. Changed hello-world.hbs adding a min-height: 1000px to the p element and a onclick="window.scrollTo(0,0)" link at the bottom of the page. New template attached
  5. Install the plugin
If you go the hello world link inside JIRA, scroll down and click Scroll Up, button does not work (window.scrollTo(0,0) from dev tools does work)
If you go to the page as standalone (localhost:3000/hello-world) scroll down and click Scroll Up, button does work going to the top of the page.

This is probably a general iframe/parent problem but I couldn't find a solution.




Dave
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Atlassian Connect Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.
hello-world.hbs

Dave Haden

unread,
Nov 13, 2015, 1:03:47 AM11/13/15
to Atlassian Connect Dev
Hey Fernando,

I was previously testing a scrollable section in the iframe where as the code that has been supplied doesnt have a scrolllable window in the iframe.
This means the only scrolling that can be done is within the top window.
Currently there are no open tickets to request so I have made ACJS-76 to hopefully cover what you are wanting to do :)

We can also continue the conversation there if you have anymore querries

Thanks
Dave
Dave
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connect-dev+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Atlassian Connect Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connect-dev+unsub...@googlegroups.com.

Fernando Boucquez

unread,
Nov 13, 2015, 10:17:15 AM11/13/15
to atlassian-...@googlegroups.com
Thank Dave, we can carry on in the issue.

I'm wondering why an Iframe cannot scroll itself?

Dave
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Atlassian Connect Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Atlassian Connect Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.

Michael Regalado

unread,
Nov 18, 2015, 1:13:31 AM11/18/15
to Atlassian Connect Dev
There is this "sizeToParent:true" attribute you can set when adding AC's js resource:

<script src="{{hostScriptUrl}}" type="text/javascript" data-options="sizeToParent:true;></script>

This will resize the iframe based on the browser's window and not the iframe's content. So if your content is larger than the browser's window, you will get a scroll but from the iframe (not from the parent's page). Then theorically the window.scrollTo(0,0) from your iframe should work.

Not sure if this solves your particular case, but could be worth a try...


Regards,
Michael
Reply all
Reply to author
Forward
0 new messages