Construct 2 scrolling down when not supposed to!

Get help using Construct 2

Post » Mon Jan 27, 2014 3:21 pm

Hi everyone,
I've recently found an issue that's driving me nuts.
The problem is i want to embed a construct 2 game on a website but i only want to show it when i scroll past some inicial pictures.

Unfortunately when construct 2 loads, it scrolls down the webpage to its position, even though i'm using iframes.

How can i fix this?
I want to prevent Construct from scrolling down the page where the game is embedded!

Thank you all,
-ViLa
B
11
S
3
Posts: 51
Reputation: 1,251

Post » Mon Jan 27, 2014 3:56 pm

Construct 2 games don't try to scroll the page. Are you sure it's not your own page doing it?
Scirra Founder
B
400
S
237
G
89
Posts: 24,550
Reputation: 195,537

Post » Mon Jan 27, 2014 4:10 pm

Hi Ashley,
I've tried loading a basic HTML page and an SWF file and both work as intended (they load up even outside the visible window).

But whenever i try to load the Construct 2 index file or another HTML page with it inside, it jumps the current page down to where it loads.

I'm using something like this:

<iframe style="padding: 0; margin: 0; border: 0;" src="http://www.url.com/index.html" height="1143" width="100%" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>

I've also tried doing that with div tags before the iframe ones but the final behaviour is the same.
B
11
S
3
Posts: 51
Reputation: 1,251

Post » Mon Jan 27, 2014 4:21 pm

Could it be anything in the index.html that pulls the focus somehow ?
Ho, and by the way, last time I used C2 inside a webpage, I prefered to use directly the canvas and start the runtime with onload :
[CODE]<div id="c2canvasdiv" width="990" height="207">
   <canvas id="c2canvas" width="990" height="207">
      <div id="c2canvas_off"></div>
   </canvas>
</div>
<script type="text/javascript">
   jQuery(document).ready(function () {
      cr_createRuntime("c2canvas");
   });
</script>[/CODE]
If it is the index that pulls the focus somehow, this would solve the problem.
B
17
S
8
G
4
Posts: 473
Reputation: 6,211

Post » Mon Jan 27, 2014 4:26 pm

AHA! Found the troublemaker!

Since you didn't expect construct 2 to have that behavior, i understood it had to be something in the code.

Then i remembered i had a "set text box to focused" on start of layout - which was scrolling down the browser window.

Removing that part fixed the issue!

Even though you didn't provide the answer, through your post i managed to find the problem!

Thank you Ashley!
B
11
S
3
Posts: 51
Reputation: 1,251

Post » Mon Jan 27, 2014 4:27 pm

[QUOTE=Guizmus] Could it be anything in the index.html that pulls the focus somehow ?
Ho, and by the way, last time I used C2 inside a webpage, I prefered to use directly the canvas and start the runtime with onload :
[CODE]<div id="c2canvasdiv" width="990" height="207">
   <canvas id="c2canvas" width="990" height="207">
      <div id="c2canvas_off"></div>
   </canvas>
</div>
<script type="text/javascript">
   jQuery(document).ready(function () {
      cr_createRuntime("c2canvas");
   });
</script>[/CODE]
If it is the index that pulls the focus somehow, this would solve the problem.[/QUOTE]

Thanks Guizmus!
I'll look into it!
That just might speed up loading and make the wepage lighter.
B
11
S
3
Posts: 51
Reputation: 1,251


Return to How do I....?

Who is online

Users browsing this forum: jezjones24, MrQuickGame and 11 guests