Hi everybody,
Help please
. I new using the Google Ajax Api and have several pages running it,
but all the images results are with safe search ON, and I want to let
this as OFF.
I have found this instructions on the Class Reference:
"The following code snippet demonstrates how to turn safe search
filtering off. var searcher = new google.search.ImageSearch();
searcher.setRestriction(google.search.Search.RESTRICT_SAFESEARCH,
google.search.Search.SAFESEARCH_OFF);
"
but I have no idea how to integrate this into my code. This Is the
code that I have in my pages:
<script src=" http://www.google.com/jsapi" type="text/javascript"></
script>
<style type="text/css">
body, table, p{
background-color: white;
font-family: Arial, sans-serif;
font-size: 13px;
}
table.search-control {
width : 100%;
}
table.search-control .gsc-control {
width : 100%;
}
td.left {
width : 100px;
padding-right : 20px;
}
td {
vertical-align : top;
}
/* Disable built in search forms */
.gsc-control form.gsc-search-box {
display : none;
}
/* restrict global search form width */
#searchForm {
width : 300px;
}
#leftSearchControl .gsc-resultsRoot {
padding-top : 6px;
}
/* for demonstration purposes ONLY. This is not ok by the terms */
#rightSearchControl .gsc-ad-box {
display : none;
}
/* long form visible urls should be on */
.gsc-webResult div.gs-visibleUrl-long {
display : block;
}
.gsc-webResult div.gs-visibleUrl-short {
display : none;
}
</style>
<script type="text/javascript">
google.load('search', '1');
// the se class encapsulates a left and right search control
// both controls are driven by a shared search form
function se() {
var sFormDiv = document.getElementById("searchForm");
var leftScDiv = document.getElementById("leftSearchControl");
var rightScDiv = document.getElementById
("rightSearchControl");
// create a left, right search control
// create a custom search form
this.leftControl = new google.search.SearchControl();
this.rightControl = new google.search.SearchControl();
this.searchForm = new google.search.SearchForm(true, sFormDiv);
// bind clear and submit functions
this.searchForm.setOnSubmitCallback(this,
se.prototype.onSubmit);
this.searchForm.setOnClearCallback(this,
se.prototype.onClear);
// set up for large result sets
this.leftControl.setResultSetSize(GSearch.LARGE_RESULTSET);
this.rightControl.setResultSetSize(GSearch.LARGE_RESULTSET);
var searcher;
var options;
// configure left control
// vertical layout, image and blog
//this.leftControl.addSearcher(new google.search.ImageSearch
());
//this.leftControl.addSearcher(new google.search.VideoSearch
());
// configure right control
// tabbed layout image, web, news, video
this.rightControl.addSearcher(new google.search.ImageSearch());
this.rightControl.addSearcher(new google.search.WebSearch());
this.rightControl.addSearcher(new google.search.NewsSearch());
this.rightControl.addSearcher(new google.search.BlogSearch());
var drawOptions = new google.search.DrawOptions();
drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
//drawOptions.setDrawMode(GSearchControl.DRAW_MODE_LINEAR);
this.rightControl.setNoResultsString
(GSearchControl.NO_RESULTS_DEFAULT_STRING);
this.leftControl.setNoResultsString
(GSearchControl.NO_RESULTS_DEFAULT_STRING);
this.leftControl.draw(leftScDiv);
this.rightControl.draw(rightScDiv, drawOptions);
// execute a starter search
this.searchForm.execute("Britney Spears");
}
// when the form fires a submit, grab its
// value and call the left and right control
se.prototype.onSubmit = function(form) {
var q = form.input.value;
if (q && q!= "") {
this.leftControl.execute(q);
this.rightControl.execute(q);
}
return false;
}
// when the form fires a clear, call the left and right control
se.prototype.onClear = function(form) {
this.leftControl.clearAllResults();
this.rightControl.clearAllResults();
form.input.value = "";
return false;
}
function OnLoad() {
new se();
}
google.setOnLoadCallback(OnLoad, true);
</script>
********************************************************************************
this is my code.
Help please, this is driving me nuts.....
--
You received this message because you are subscribed to the Google Groups
"Google AJAX APIs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en.