0

I want to create a dynamic height Iframe.

I am building a custom search engine in which i have to show my data with the google search data.

Means: If i enter "asdq" in the search textbox then it will show my data result with custom google search result.

I want to change the height of the iframe accordant to the content send by the google. Means:Let Google send 10 row then my iframe size will be 100px if Google send 1 data then 10px etc.

If I fix the height of the iframe then scroll bar comes to the iframe if more data come from Google.

you can see my problem here

Actually i want to remove the scroll bar of the iframe so that only one scroll bar will be there that is pages scroll bar.

please help

Thanks in advance.

bhagirathi
  • 521
  • 6
  • 23
  • See this answer: http://stackoverflow.com/a/9163087/1726343 – Asad Saeeduddin Nov 07 '12 at 11:27
  • Don't specify the iFrame height (or set to 100%) and remove overflow CSS attributes – sdespont Nov 07 '12 at 11:27
  • I tried this
    this is not working
    – bhagirathi Nov 07 '12 at 11:32
  • Asad it is giving error like this Unsafe JavaScript attempt to access frame with URL http://www.google.com/cse?cx=009827885688477640989%3Aigzwimalyta&ie=UTF-8&q=asd#gsc.tab=0&gsc.q=asd&gsc.page=1 from frame with URL http://192.168.9.185/KLMS/CustomGoogleSearch.aspx. Domains, protocols and ports must match. – bhagirathi Nov 07 '12 at 11:34

1 Answers1

2

We can't set the size of Iframe if it is getting data from other domain means if we don't have access to the body of the iframe.

We can use this to over come form this problem.

<script type="text/javascript">
    google.load('search', '1'); // loads Google Search library, v 1
// get a custom search control & keep it in cseControl
// note: put your own custom search ID number here
var cseControl = new  google.search.CustomSearchControl('009827885688477640989:igzwimalyta');
// open pages from search results clicks on the same page
cseControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
// when there are no matches, explain why
cseControl.setNoResultsString("Sorry, there are no pages in this web site that match  all the search terms.");
// make the search field visible in div with ID 'cseDiv'
cseControl.draw('divGoogleResult');

 cseControl.execute(userInput);

</script>