frankdevhub / frankdevhub.github.io

Blog template powered by jekyll to share the interesting stories in life (基于Jekyll的模板引擎的维基风格的个人博客,记录分享生活中的新鲜故事)
http://blog.frankdevhub.site
MIT License
5 stars 3 forks source link

how to get scrollbar worked on css of iframe component when using js like this ? #30

Closed frankdevhub closed 5 years ago

frankdevhub commented 5 years ago

@MaoJianwei Hi, Mao~ Thanks for demo you shared on Github 2 years ago, i do really learned much from your ONOS demo, that was really awesome! Here may i need some help from u ?

The problem is i am now building a personal blog using jekyll framework. At the home page i want to post the article which refers to a new online game.

In the post, i use iframe component to display the official website page of this game.

Problem(Need Help): How to use js script to make the iframe scroll on Y direction to get a better default view when iframe component is loaded.

Method have tried but not work:

<iframe frameborder="0" id="arma2_iframe" display="block" scrolling="yes" height="400px" id="arma2_official"
    overflow:visible width="100%" src="http://arma2.com" allowFullScreen="true">
</iframe>

<script type="text/javascript">
  $(document).ready(function(){
       var armaIframe = $("#arma2_iframe");
            armaIframe.onload = function(){
            armaIframe.contentWindow.scrollTo(0,500); // i want to get scroll worked but still not working.
        };
  });

</script>

Thanks !

image

jeffslofish commented 5 years ago

Hi, I was just browsing around and saw your issue and thought I could help.... Your iframe has two ids, which is a no-no. Try removing id="arma2_official" and see if that helps.

frankdevhub commented 5 years ago

@jeffslofish Hi,jeffslofish. Thanks for guide. That was a terrible and careless mistake. However i tried again and still not worked.

I searched and followed the document which appears to work but still achieve nothing. broswer: chrome

Here is the page i followed: the demolink @jsbin.com

Thanks again! Franklinfang

image

jeffslofish commented 5 years ago

I could take a look on my system....what commands do I run to build and run your site using my forked clone?

frankdevhub commented 5 years ago

I could take a look on my system....what commands do I run to build and run your site using my forked clone?

@jeffslofish Thanks bro! My operating sys is windows. Here is the way to build and run the application: 1.Install Ruby and config path variable. then check:

ruby -v

2.install Ruby DevKit (Mac may not need t install)

ruby dk.rb init
ruby dk.rb install

3.install jekyll

gem install jekyll

4.fork and run

jekyll build
jekyll serve
jeffslofish commented 5 years ago

Unfortunately, I believe due to cross-origin security policies, this is not possible.

frankdevhub commented 5 years ago

like jeffslofish said. @jeffslofish