Yea! Now after years of applications work I have finally bit the bullet and gotten myself a website playground. But I am running into a problem. I want to be able to make some money off this site when a user wants to search for something. So I set up google to be my search engine of choice and whenever someone searches something google populates a div in my search.php with the information returned from their servers. Here is what the code looks like: -
<div id="googleSearchUnitIframe"> </div>
-
<script type="text/javascript">
-
var winW = 630;//default
-
if (parseInt(navigator.appVersion)>3) {
-
if (navigator.appName=="Netscape") {
-
winW = window.innerWidth;
-
}
-
if (navigator.appName.indexOf("Microsoft")!=-1) {
-
winW = document.body.offsetWidth;
-
}
-
}
-
-
-
var googleSearchIframeName = 'googleSearchUnitIframe';
-
var googleSearchFrameWidth = winW * .76;
-
var googleSearchFrameborder = 0 ;
-
var googleSearchDomain = 'www.google.com';
-
</script> <script type="text/javascript"
-
src="http://www.google.com/afsonline/show_afs_search.js">
-
</script></div>
As you can see I create a blank div called googleSearchUnitIframe that google then puts its information in. I also specify the framewidth and frameborder which I try to do dynamically whenever the page loads (well not the border). My nav bar is on the right that is why the width needs to be multiplied by .76.
This little javascript actually works great, but what I am trying to do is handle if/when the user wants to resize their browser window. At this point the google frame will stay the same size and everything will resize behind it. I want to make it so that the googleSearchFrameWidth will be recalculated everytime the user presses F5(which it does now) or resizes the window(which it does not do now). It may require the page to be reloaded whenever the window is resized, that is fine. I don't mind a google search request being resent everytime the window is resized.
What c0dez r ur going to give me to m4ke it werk?!?!?!1!!11eleven!! Need help plz pzl plzzzzzz.
15 3143
What c0dez r ur going to give me to m4ke it werk?!?!?!1!!11eleven!! Need help plz pzl plzzzzzz.
Please type in clear English. Thanks!
Changed the thread title. I think you need a reminder of the posting guidelines.
Couldn't you just set your div dimension to a percentage of the overall size?
Couldn't you just set your div dimension to a percentage of the overall size?
I tried to make some changes to the CSS so that the div would work properly. the Iframe div does inherit its size and padding from the body div. It looks like google's js overrides what my CSS says because of the - var googleSearchFrameWidth = winW * .76;
part. So not sure if this is the correct answer, give me some tips about what kind of CSS changes to try and in what divs, and I'll test all possible permutations to see if I can make it behave.
onresize ?
I tried handling that. But I could not get it to refresh the screen. I also tried to recalculate the width using the same methods that I did when the page is first loaded, but while it does report the proper width it does not resize google's js. I think I will need to run the query to google again after the screen resizes so that they can put the newly resized information in my blank div.
I tried to make some changes to the CSS so that the div would work properly. the Iframe div does inherit its size and padding from the body div. It looks like google's js overrides what my CSS says because of the - var googleSearchFrameWidth = winW * .76;
part. So not sure if this is the correct answer, give me some tips about what kind of CSS changes to try and in what divs, and I'll test all possible permutations to see if I can make it behave.
You could try the width property, but I don't know the inner workings of Google's script. Does it expect a number and not a percentage?
I tried handling that. But I could not get it to refresh the screen. I also tried to recalculate the width using the same methods that I did when the page is first loaded, but while it does report the proper width it does not resize google's js. I think I will need to run the query to google again after the screen resizes so that they can put the newly resized information in my blank div.
If Google's not responding to the width change, it probably means that you'll have to run the query again.
You could try the width property, but I don't know the inner workings of Google's script. Does it expect a number and not a percentage?
Google requries an integer not a %
If Google's not responding to the width change, it probably means that you'll have to run the query again.
Ok so how do I refresh the page on resize to send the query again?
Google requries an integer not a %
Wait a minute, have you tried setting the width after the Google script? - document.getElementById("googleSearchUnitIframe").style.width=winW*.76;
Wait a minute, have you tried setting the width after the Google script? - document.getElementById("googleSearchUnitIframe").style.width=winW*.76;
no ...
Yea that doesnt work because that variable needs to be set before the request is made to google to display the search results.
Yea that doesnt work because that variable needs to be set before the request is made to google to display the search results.
The variable needs to be set before, but you can alter the width of the div after the request surely?
The variable needs to be set before, but you can alter the width of the div after the request surely?
Yes you can but it looks like google formats the output from the query based on what value you give it before hand. So it is important to make them match otherwise all of the results will be cut off, and that is not very helpful.
Ok so how do I refresh the page on resize to send the query again?
You can either refresh the page using - window.location.reload();
but that seems a bit overkill, or just send the query again to refresh the div. You would do that by finding out the new variable values and calling the script again. To run the script, you'll have to add it dynamically to the page, e.g. - var script = document.createElement("script");
-
script.setAttribute("type","text/javascript");
-
script.setAttribute("src",...);
and then append it to the body using appendChild.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matt |
last post by:
I use CSS for positionings in my html page, the problem is when i
resize the browser, the positions are offset. Here's the code, any
ideas??
<html>
<head>
<style type="text/css">
|
by: David Hayes |
last post by:
juglesh <juglesh@nospamRadioKDUG.com> wrote in "Re: how to maximize the
browser window that fits the monitor size?" (Saturday, January 01, 2005 3:12
AM):
>
> >I want to maximize the browser...
|
by: Giggle Girl |
last post by:
Hi there,
I am having a problem with the behavior of Firefox, where lefthand
column content is not resized properly after it is "collapsed" and then
"re-expanded". An online demo is available...
|
by: RC |
last post by:
I know how to do this in JavaScript by
window.open("newFile.html",
"newTarget",
"scrollbars=no,resizable=0,width=200,height=200");
The browser will open a new window size 200x200, not allow...
|
by: hash4sp |
last post by:
Hi !
I have a problem with my frame size. The frame is used to display results
in form of html table generated dynamically. Sometimes the frame resizes
its height according to the content in...
|
by: Doug Gunnoe |
last post by:
I'm considering resizing a div onload to better match the screen width
of the user.
Easy enough, however it seems that I have read in this group that
there are potential problems with this,...
|
by: =?Utf-8?B?UiBSZXllcw==?= |
last post by:
Hi!
This discussion may help other programmers get a better idea of how to save
uploaded images through a website.
Why? Well currently, I save 3 versions of every uploaded image on my own...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |