Ever thought about having to open up a Iframe but just wanting to show a cropped set of contents inside it. ie, You want to show only a section of the page minus its top menu and its
left menu.
Well there is a rather convenient way I found out after researching on various webmasters forums. But I found it only worked smoothly opening it up in a popup window. And assuming you are using IE on a set of Internal sites. For example, we have 2 Internal Browser based sites. We just want some content to be fired up from site one in a popup window containing content in the second site minus the top and left menus. Here is what I had to do.
In Site A, Simply create a link and get the link to open in a new target window.
Link to a HTML Page with the following code. Make the Height and the width about how big your cropped section needs to be. In this case I have set 750 height by 820 width.
<script type="text/javascript">
var strParam1 = "Start.html";
winRef = window.open(strParam1,"My_Window","height=750,left=320,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,titlebar=no,toolbar=no,top=230,width=820",false);
// Fool it to open a blank window so that it can close without prompting in JavaScript.
window.open('', '_self', '');
window.close();
winRef.focus();
//}
</script>
Then you can see, there is a second page that needs to be created that this page opens to its content. In this case I have called it Start.html.
In this page just put in this simple IFRAME HTML code.
<table>
<tr>
<td>
<iframe src="http://mydomain.com/default.aspx" width="1400px" height="1080px" name="myframe" style="position:absolute; top:-190px; left: -150px; right:-200px; overflow:
hidden;"></iframe>
</td>
</tr>
</table>
This fires the frame inside the popup window and the style property of top -190 and left -150 and right -200. Re-positions the target content within the frame so that it looks like it has been cropped. Because you have set the popup window size and has suppressed the scrollbars, user can't scroll to see the top or left hand side menu.
Show By Category
.NET Service
(1)
1909
(1)
ACTV
(1)
adidas
(47)
adizero
(1)
Admiral
(9)
Airness
(3)
Albania
(3)
Algeria
(3)
America Mineiro
(1)
Angola
(1)
Anta
(2)
Argentina
(2)
Armenia
(1)
Atletico Goianiense
(1)
Atletico Paranaense
(1)
Austria
(2)
Authentic fit
(1)
Auto Generate from Access
(1)
Avai FC
(1)
avoid
(2)
Bahia
(1)
Beijing Guoan
(1)
Belgium
(4)
Benin
(1)
Birmingham City
(1)
Bolivia
(1)
Boot Configuration Data missing
(1)
Bosnia
(1)
Botafogo
(2)
Botafogo SP
(1)
Botswana
(2)
Brazil
(4)
Brazilian brand
(15)
Bulgaria
(2)
Burkina Faso
(2)
Burrda
(3)
Bypass traverse checking
(1)
Cambodia
(1)
Cameroon
(4)
Ceara
(1)
CEWP
(2)
Chapecoense
(2)
Chile
(3)
China
(9)
Chinese Brand
(4)
Chongqing Lifan Dangdai
(1)
Club Deportivo Universidad Catolica
(1)
Club Universitario de Deportes
(1)
Clube de Remo
(1)
Colombia
(6)
Colombian Brand
(1)
Congo DR
(1)
Congo Rep
(1)
Copa America
(3)
Corinthians
(1)
Coritiba
(1)
Costa Rica
(2)
Cote d'Ivoire
(3)
Coventry City
(1)
Croatia
(2)
Crop IFRAME
(1)
Cruzeiro
(2)
Crystal Palace
(4)
css
(3)
Cuba
(1)
Cyprus
(1)
Czech Republic
(2)
Deleting large libraries
(2)
Denmark
(2)
design fault
(2)
Diadora
(1)
Dragao Premium
(1)
eagles
(1)
Ecuador
(3)
Ecuadorian Brand
(3)
Egypt
(1)
El Salvador
(1)
electrical
(2)
electrical problems
(2)
electrocuted
(2)
England
(3)
Errea
(3)
Espanyol
(1)
Ethiopia
(1)
Euro 16
(10)
Excel 2010
(3)
External Content Type
(1)
FBT
(3)
FC Porto
(1)
Fenerbahce
(1)
Figueirense
(1)
Finland
(1)
Fiorentina
(1)
Flamengo
(1)
Flickering
(1)
Fluminense
(1)
football
(233)
Fortuna Dusseldorf
(1)
France
(2)
futfanatics.net
(1)
Gabon
(1)
Germany
(1)
Ghana
(2)
Gogoalshop
(2)
Goias
(1)
Granada CF
(1)
Grand Sport
(2)
Greece
(2)
Green
(1)
Guangzhou Evergrande
(1)
Guinea
(1)
Guinea Bissau
(1)
Haiti
(1)
Heilongjiang Lava Spring
(1)
Honduras
(1)
Hong Kong
(1)
Hummel
(1)
Hungary
(1)
Iceland
(3)
Icone Sports
(2)
IE Developer Tools
(1)
India
(1)
Indian Brand
(1)
Internal Field Names
(1)
Italy
(2)
Jako
(1)
Jamaica
(2)
Japan
(1)
Javascript
(6)
Jersey
(126)
Jiangsu Suning FC
(1)
Joma
(5)
Kanxa
(1)
Kappa
(3)
Kelme
(4)
Kenya
(1)
kitchen extractor fan
(3)
Korea
(1)
Laos
(1)
Le Coq Sportif
(1)
leak
(2)
Legea
(1)
Levante
(1)
Li Ning
(3)
Local Security Policy
(1)
Login Problem
(1)
Lotto
(4)
Lupo
(2)
Macron
(9)
Mafro
(3)
Mali
(3)
Man Utd
(1)
Marathon Sports
(6)
Marseilles
(1)
masterpage
(1)
Meizhou Hakka
(1)
Mexico
(5)
Modena Volley
(1)
Montenegro
(1)
Morocco
(3)
Myanmar
(1)
N98
(1)
Naija
(1)
Nakal
(1)
Namibia
(1)
Napoli
(1)
Netherlands
(1)
New Balance
(2)
Newcastle United
(2)
Niger
(1)
Nigeria
(4)
Nike
(32)
Nike Brasil
(1)
Nike Brazil
(1)
Nike China
(12)
Nike South Africa
(1)
North Macedonia
(1)
Norway
(1)
O'Neills
(1)
Oldham Athletic
(1)
Olympikus
(1)
Olympique Lyonnais
(1)
Page Viewer WebPart
(1)
Panama
(2)
Para
(1)
Paraguay
(2)
Penalty
(1)
Peru
(6)
Picture Manager
(1)
Poland
(2)
Ponte Preta
(1)
Portugal
(2)
Portuguesa RJ
(1)
problem
(2)
Puma
(46)
retro
(1)
review
(111)
Romai
(2)
Romania
(1)
RT Sports
(1)
Russia
(4)
Saeta
(1)
Sampaio Correa
(1)
Santarem
(1)
Santos
(2)
Sao Paulo FC
(1)
Sao Raimundo
(1)
scam
(2)
Score Draw
(1)
Search List with Count Displayed
(1)
Senegal
(3)
Serbia
(1)
Server Hardening
(1)
SESI Sao Paulo
(1)
Shandong Luneng
(1)
Shanghai Shenhua
(1)
Shanghai SIPG
(1)
SharePoint
(61)
SharePoint Connect to SQL
(2)
SharePoint Designer
(3)
Shenzhen FC
(1)
shirt
(232)
Sierra Leone
(1)
Singaporean Brand
(2)
Six5Six
(1)
Slovakia
(2)
Slovenia
(1)
Slow right click
(1)
Sondico
(1)
South Africa
(1)
Spain
(3)
SPS Services
(2)
Spurs
(1)
SQL Server 2008
(1)
SSP User Profile behaviour
(1)
Super Bolla
(2)
Sweden
(2)
Switzerland
(2)
Taubate Funvic
(1)
Team GB
(2)
techfit
(8)
Thai Brand
(3)
Thailand
(2)
Togo
(1)
Topper
(4)
track top
(13)
Travels
(1)
Trinidad and Tobago
(1)
Tunisia
(3)
Turkiye
(1)
tyro
(1)
UAE
(1)
UB
(3)
UB Electric
(3)
Ucan
(1)
UE Llagostera
(1)
Uganda
(1)
Uhlsport
(2)
Ukraine
(1)
Umbro
(18)
Umbro Brazil
(6)
Under Armour
(3)
Upload Center
(1)
Uruguay
(1)
Vasco Da Gama
(1)
Venezuela
(1)
Vietnam
(1)
Villa Nova
(1)
Villarreal
(1)
Vitoria
(1)
volleyball
(6)
Vozao
(1)
Wales
(1)
Warrix
(1)
water
(2)
WebClient
(4)
WebDav
(5)
West Ham
(2)
Where to get buy Iceland football shirt in Reykjavik
(1)
Win 8
(2)
Windows 10
(1)
Windows Scheduled Task
(1)
wish list
(1)
Workflow
(1)
World Cup 14
(9)
World Cup 18
(5)
Wuhan Zall
(1)
Xinjiang Tianshan Leopard
(1)
Xtep
(1)
Yanbian Funde
(1)
Yemen
(1)
Zambia
(1)
Zhejiang Greentown
(2)
Zimbabwe
(1)
Thursday, 19 December 2013
Tuesday, 10 December 2013
When Retracting Solutions - SharePoint Admin Services Must Run on All WFE and APP Servers in Farm
Whilst trying to perform a simple task of retracting a solution or package from a SharePoint 2007 Web application. There it showed an error in the retraction status. In the Timer Job Status under Global Configuration section in the Central Admin, there will be an error entry for the solution's retraction.
After some digging around, it seemed like one of the root causes of the problem was that we have a WFE Server and an Application Server in the farm. Even though the Application Server had served no Web Site, it was essential that the Windows SharePoint Administration Service is running. If it is not, this type of action on the Central Admin Console do not fully run.
Anyway, started the service then in order to refresh the status. We need to do into the Central Admin's Global Configuration - > Time Job Definitions. Remove the error job that is hanging there for the retraction. Then use stsadmin in the 12 Bin drectory and run a
retractsolution command
stsadm -o retractsolution -name <solution name> [-url] <URL name>
or retractwppack command if it was a .cab file
stsadm -o retractwppack -name <name> -url <URL name> -immediate
and voila problem cleared.
After some digging around, it seemed like one of the root causes of the problem was that we have a WFE Server and an Application Server in the farm. Even though the Application Server had served no Web Site, it was essential that the Windows SharePoint Administration Service is running. If it is not, this type of action on the Central Admin Console do not fully run.
Anyway, started the service then in order to refresh the status. We need to do into the Central Admin's Global Configuration - > Time Job Definitions. Remove the error job that is hanging there for the retraction. Then use stsadmin in the 12 Bin drectory and run a
retractsolution command
stsadm -o retractsolution -name <solution name> [-url] <URL name>
or retractwppack command if it was a .cab file
stsadm -o retractwppack -name <name> -url <URL name> -immediate
and voila problem cleared.
Friday, 6 December 2013
Look Up Online WebService in a OOTB SharePoint form
Adapated some script to allow a SharePoint OOTB form for one of its fields to call an XML Web Service to return an array of data.
For example, we have a field for a Finance Ticker, user types the ticker code as they type, it takes what has been typed in so far and queries an online web service that can lookup these codes, for example google and yahoo have this service and so do some other finance institutes.
<script type="text/javascript" src="http://xyz.com/SiteCollectionDocuments/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
// Get all top level Keywords from Global Compass Site.
function getKeyWords()
{
$(document).ready(function() {
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>Pre-defined Tags</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
<FieldRef Name='ID' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
url: "http://xyz.com/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processKeyWords,
contentType: "text/xml; charset=\"utf-8\""
});
});
}
function processKeyWords(xData, status)
{
var strForDropDown = "";
$(xData.responseXML).find("z\\:row").each(function() {
strForDropDown = strForDropDown + $(this).attr("ows_Title") + "@" + $(this).attr("ows_ID") + "|";
});
// Now populate the keyword dropdown with our extracted data
populateGlobalCompassKeywordDropDown(strForDropDown);
}
//populate the keyword drop down
function populateGlobalCompassKeywordDropDown(strValues)
{
//Clear the dropdown if there is anything.
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl06_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options.length = 0;
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl06_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options[0] = new Option("(None)", "None");
if (strValues != "")
{
var item_array = strValues.split("|");
for (var iCount = 0; iCount < (item_array.length-1); iCount++)
{
//alert(item_array[iCount].toString());
var items = item_array[iCount].split("@");
try
{
// Force "None" into all values because it needs this value to fool SharePoint into accepting it when saving
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl06_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options[iCount+1] = new Option(items[0], "None");
}
catch(ex)
{
alert("Possible array out of bound error - populateGlobalCompassKeywordDropDown(strValues)");
}
}
}
else
{
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl06_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options[0] = new Option("(None)", "None");
}
}
// Get all research docs containing keyword that was selected from Global Compass Site.
function getResearchDocs()
{
var strValueSelected = document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl06_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options[document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl06_ctl00_ctl00_ctl04_ctl00_DropDownChoice.selectedIndex].text;
strValueSelected = strValueSelected.replace("&","&")
$(document).ready(function() {
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>Pages</listName> \
<query><Query><Where><Contains><FieldRef Name='TagsFieldForKWizComTags1'/><Value Type='Text'>"+strValueSelected+"</Value></Contains></Where><OrderBy><FieldRef Name='Title' Ascending='TRUE' /></OrderBy></Query></query> \
<viewFields> \
<ViewFields> \
<FieldRef Name='FileRef' /> \
<FieldRef Name='Title' /> \
<FieldRef Name='ID' /> \
<FieldRef Name='FileLeafRef' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
url: "http://xyz.com/globalcompass/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResearchDocs,
contentType: "text/xml; charset=\"utf-8\""
});
});
}
function processResearchDocs(xData, status)
{
var strForDropDown = "";
$(xData.responseXML).find("z\\:row").each(function() {
strForDropDown = strForDropDown + $(this).attr("ows_FileRef") + "@" + $(this).attr("ows_Title") + "|";
});
// Now populate the department dropdown with our extracted data
populateGlobalCompassDocumentDropDown(strForDropDown);
}
//populate the Global Compass Document drop down
function populateGlobalCompassDocumentDropDown(strValues)
{
//Clear the dropdown if there is anything.
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options.length = 0;
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options[0] = new Option("(None)", "None");
if (strValues != "")
{
var item_array = strValues.split("|");
for (var iCount = 0; iCount < (item_array.length-1); iCount++)
{
//alert(item_array[iCount].toString());
var items = item_array[iCount].split("@");
try
{
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options[iCount+1] = new Option(items[1], items[0]);
}
catch(ex)
{
alert("Possible array out of bound error - populateGlobalCompassDocumentDropDown(strValues)");
}
}
}
else
{
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options[0] = new Option("(None)", "None");
}
}
// Function that sets the URL of the selected research papers to the event into the
// Rich Text box that is used to hold the Associated research field.
function setText()
{
var strHostname = window.location.hostname;
var strURL = document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options[document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.selectedIndex].value;
var item_array = strURL.split("#");
strURL = "http://"+strHostname+"/"+item_array[1];
var strResearchDocumentName = document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options[document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.selectedIndex].text;
var xFrame = document.getElementById("ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_iframe");
var superString = "<a href='"+strURL+"' target='_blank'>"+strResearchDocumentName+"</a><br>";
xFrame.contentWindow.document.body.innerHTML += "<a target='_blank' href='"+strURL+"'>"+strResearchDocumentName+"</a><br>";
var strStringToSave = xFrame.contentWindow.document.body.innerHTML;
strStringToSave = strStringToSave.replace("<P> </P>", "");
xFrame.contentWindow.document.body.innerHTML = strStringToSave;
}
// function to override default save actions
// we need to reset the global compass document to None so SharePoint will save because it is expecting this value in its integrity check.
function setGlobalCompassDocumentToNoneBeforeSave()
{
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.selectedIndex = 0;
//alert(document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.options[document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.selectedIndex].value);
if (!PreSaveItem()) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$m$g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem", "", true, "", "", false, true));
if (!PreSaveItem()) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$m$g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554$ctl00$toolBarTbltop$RightRptControls$ctl01$ctl00$diidIOSaveItem", "", true, "", "", false, true));
return true
}
getKeyWords();
// Add the onchange event so that next time its selection is changed, it will trigger a JQuery call to lookup the research docs.
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl06_ctl00_ctl00_ctl04_ctl00_DropDownChoice.setAttribute("onchange", getResearchDocs);
// Add the onchange event so when an article is selected its URL reference link gets populates into the Research box text box.
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice.setAttribute("onchange", setText);
// Add onclick event to intercept save button actions
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_toolBarTbltop_RightRptControls_ctl01_ctl00_diidIOSaveItem.setAttribute("onclick", setGlobalCompassDocumentToNoneBeforeSave);
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_diidIOSaveItem.setAttribute("onclick", setGlobalCompassDocumentToNoneBeforeSave);
document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl13_ctl00_ctl00_ctl04_ctl00_ctl00_TextField.setAttribute("onkeydown", showResultGoogleProtoType);
//document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl13_ctl00_ctl00_ctl04_ctl00_ctl00_TextField.setAttribute("onkeyup", setSelectedColour);
//document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl13_ctl00_ctl00_ctl04_ctl00_ctl00_TextField.setAttribute("onkeypress", showResultGoogleProtoType);
///////////////////////
// Stock lookup section
function waitSeconds()
{
var x = 0;
for(var nCount=0; nCount<10000; nCount++)
{
x++;
}
}
function setSelectedColour()
{
//alert("Set");
var e = window.event;
var nMaxRows = getMaxRowsInTable();
switch(e.keyCode)
{
case 38: // up key
//alert("Up");
waitSeconds();
break;
case 40: // down key
//alert("Down");
waitSeconds();
break;
case 13: // Enter key
alert("Enter");
break;
}
var objTable = document.getElementById("recordTab1");
if (objTable)
{
if (gnSelectedIndex < nMaxRows)
{
var objTR = objTable.getElementsByTagName("tr")[gnSelectedIndex];
$(document).ready(function(){
objTR.style.background="#ffbe6b";});
}
}
}
// Function that looks up what was typed in and calls External Web Service to bring back the matches
function showResult()
{
var e = window.event;
var nMaxRows = getMaxRowsInTable();
switch(e.keyCode)
{
case 38: // up key
ScrollUpSelectedIndex(nMaxRows);
break;
case 40: // down key
ScrollDownSelectedIndex(nMaxRows);
break;
case 13: // Enter key
GetSelectedRow();
break;
}
var str = document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl13_ctl00_ctl00_ctl04_ctl00_ctl00_TextField.value;
document.getElementById("livesearch").style.display = "block";
if (str.length==0)
{
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.border="0px";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var strOutputHTML = xmlhttp.responseText;
//alert(strOutputHTML);
var strEnteredValue = str;
strEnteredValue = "," + strEnteredValue;
strOutputHTML = replaceAll(strOutputHTML, "#ffffcc", "#deebde");
strOutputHTML = replaceAll(strOutputHTML, "#ccffff", "#ffbe6b");
strOutputHTML = replaceAll(strOutputHTML, "false", "");
strOutputHTML = replaceAll(strOutputHTML, strEnteredValue, "");
strOutputHTML = strOutputHTML + "<table width='100%' cellspacing='0' cellpadding='2' ><tr><td align='right' class='content_TC_td_a'><a href='JavaScript:closeme();'>Close</a></td></tr>";
document.getElementById("livesearch").innerHTML=strOutputHTML;
document.getElementById("livesearch").style.border="1px solid #A5ACB2";
document.getElementById("livesearch").style.border="1px solid #006939";
}
}
xmlhttp.open("GET","http://www.quamnet.com/stocksearchboxajax.action?formName=quotefrm&stockName="+str,true);
//xmlhttp.open("GET","http://www.google.com/finance/match?matchtype=matchall&q="+str,true);
xmlhttp.send();
}
function showResultGoogleProtoType()
{
var str = document.forms['aspnetForm'].ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl13_ctl00_ctl00_ctl04_ctl00_ctl00_TextField.value;
document.getElementById("livesearch").style.display = "block";
if (str.length==0)
{
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.border="0px";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var strOutputHTML = xmlhttp.responseText;
//var strEnteredValue = str;
//strEnteredValue = "," + strEnteredValue;
strOutputHTML = strOutputHTML.replace("{\n\"matches\" : [\n", "");
strOutputHTML = strOutputHTML.replace("],\"all\":false}", "");
strOutputHTML = strOutputHTML.replace("],\"all\":true}", "");
strOutputHTML = replaceAll(strOutputHTML, '"', "");
//],"all":true}
//alert(strOutputHTML);
var objSuggestions = strOutputHTML.split("}\n,{");
var strSanitised;
for(var nCount=0; nCount < objSuggestions.length; nCount++)
{
var objSubArray = objSuggestions[nCount].split(":");
strSanitised += objSubArray[1];
strSanitised += "|";
strSanitised += objSubArray[2];
strSanitised += "|";
strSanitised += objSubArray[3];
strSanitised += "\n";
}
//alert("San 1 "+"\n"+strSanitised);
//strSanitised = replaceAll(strSanitised, "e:", "");
strSanitised = replaceAll(strSanitised, ", e", "");
//strSanitised = replaceAll(strSanitised, "n:", "");
strSanitised = replaceAll(strSanitised, ", n", "");
//strSanitised = replaceAll(strSanitised, "t:", "");
//strSanitised = replaceAll(strSanitised, "t|", "");
strSanitised = replaceAll(strSanitised, "undefined{", "");
strSanitised = replaceAll(strSanitised, ", id", "");
strSanitised = replaceAll(strSanitised, "undefined", "");
//alert("San 2 "+"\n"+strSanitised);
var strHTMLTable = makeHTMLTable(strSanitised);
//alert(strHTMLTable);
//strOutputHTML = replaceAll(strOutputHTML, "false", "");
//strOutputHTML = replaceAll(strOutputHTML, strEnteredValue, "");
strHTMLTable = strHTMLTable + "<table width='100%' cellspacing='0' cellpadding='2' ><tr><td align='right' class='content_TC_td_a'><a href='JavaScript:closeme();'>Close</a></td></tr></table>";
//document.write(strHTMLTable);
document.getElementById("livesearch").innerHTML=strHTMLTable;
document.getElementById("livesearch").style.border="1px solid #A5ACB2";
document.getElementById("livesearch").style.border="1px solid #006939";
}
}
//xmlhttp.open("GET","http://www.quamnet.com/stocksearchboxajax.action?formName=quotefrm&stockName="+str,true);
xmlhttp.open("GET","http://www.google.com/finance/match?matchtype=matchall&q="+str,true);
xmlhttp.send();
var e = window.event;
var nMaxRows = getMaxRowsInTable();
switch(e.keyCode)
{
case 38: // up key
ScrollUpSelectedIndex(nMaxRows);
break;
case 40: // down key
ScrollDownSelectedIndex(nMaxRows);
break;
case 13: // Enter key
GetSelectedRow();
break;
}
}
// A function that processes our sanitised string into HTML table format to be placed into a Div's InnerHTML for presentation
function makeHTMLTable(strSanitised)
{
var strReturn = "<table width='480px' id='recordTab1' border='0' cellspacing='0' cellpadding='0' style='background:#deebde;'>";
var objRecord = strSanitised.split("\n");
for(var nCount=0; nCount < objRecord.length; nCount++)
{
var objItem = objRecord[nCount].split("|");
//alert(objItem.length);
if (objItem.length == 3)
{
if(objItem[0] != "" && objItem[1] != "" && objItem[2] != "")
{
strReturn += "<tr onmouseover='this.style.background=\"#ffbe6b\";SetSelectIndex("+ nCount +");' onmouseout='this.style.background=\"#deebde\"' style=\"cursor:pointer;\" onclick=\"selectValue('" + objItem[2] + "','" + objItem[0] + "')\">";
strReturn += "<td class=content_TC_td_a width='15%'>"+ objItem[0] +"</td>";
strReturn += "<td class=content_TC_td_a width='70%'>"+ objItem[1] +"</td>";
strReturn += "<td class=content_TC_td_a width='15%'>"+ objItem[2] +"</td></tr>";
}
}
else
{
// alert("Something was undefined..");
}
}
strReturn += "</table>";
return strReturn;
}
// function that invokes a Google Finance display details window for stock code selected
function selectValue(strExchangeName, strCode)
{
document.getElementById("ctl00_m_g_53cc0ef7_5cec_44ae_ab5b_55bf562e4554_ctl00_ctl04_ctl13_ctl00_ctl00_ctl04_ctl00_ctl00_TextField").value = strCode;
document.getElementById("livesearch").style.display = "none";
var strParam = strExchangeName + ":";
strParam = strParam + strCode;
strParam = "http://www.google.com/finance?q=" + strParam + "&client=news#";
winRef = window.open(strParam,"MAM_Google_Info","height=600,left=900,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,top=100,width=750",false);
winRef.focus();
}
// function to close the stock list's div
function closeme()
{
document.getElementById("livesearch").style.display = "none";
}
// a replace all string function
function replaceAll(txt, replace, with_this) { return txt.replace(new RegExp(replace, 'g'),with_this);}
// Variable for our Google Finance lookup window
var winRef;
// Variable for current selected Row
var gnSelectedIndex = 0;
// Variable to track the current select row's cell value
var gnCurrentTableRowCellValue = 0;
// function that moves the selected row of stock entries up
function ScrollUpSelectedIndex(nMaxRowsInTable)
{
if (gnSelectedIndex > 0 && gnSelectedIndex < nMaxRowsInTable)
{
var objTable = document.getElementById("recordTab1");
var objTR = objTable.getElementsByTagName("tr")[gnSelectedIndex -1];
var objTRPrevious = objTable.getElementsByTagName("tr")[gnSelectedIndex];
objTR.style.background="#ffbe6b";
objTRPrevious.style.background="#deebde";
gnSelectedIndex = gnSelectedIndex - 1;
gnCurrentTableRowCellValue = gnSelectedIndex;
}
else
{
if (gnSelectedIndex == nMaxRowsInTable)
{
var objTable = document.getElementById("recordTab1");
var objTR = objTable.getElementsByTagName("tr")[gnSelectedIndex-2];
var objTRPrevious = objTable.getElementsByTagName("tr")[gnSelectedIndex-1];
objTR.style.background="#ffbe6b";
objTRPrevious.style.background="#deebde";
gnSelectedIndex = gnSelectedIndex - 2;
gnCurrentTableRowCellValue = gnSelectedIndex;
}
}
}
// function that moves the selected row of stock entries down
function ScrollDownSelectedIndex(nMaxRowsInTable)
{
if (gnSelectedIndex < nMaxRowsInTable) // Need to work our max number
{
if (gnSelectedIndex == 0)
{
var objTable = document.getElementById("recordTab1");
var objTR = objTable.getElementsByTagName("tr")[gnSelectedIndex];
objTR.style.background="#ffbe6b";
}
else
{
var objTable = document.getElementById("recordTab1");
var objTR = objTable.getElementsByTagName("tr")[gnSelectedIndex];
var objTRPrevious = objTable.getElementsByTagName("tr")[gnSelectedIndex-1];
objTR.style.background="#ffbe6b";
objTRPrevious.style.background="#deebde";
}
gnCurrentTableRowCellValue = gnSelectedIndex;
gnSelectedIndex = gnSelectedIndex + 1;
}
}
// Gets / traps the current selected row's cell value based on an enter keey being pressed
function GetSelectedRow()
{
var objTable = document.getElementById("recordTab1");
var objTR = objTable.getElementsByTagName("tr")[gnCurrentTableRowCellValue];
var objTD = objTR.getElementsByTagName("td")[0];
// first item element of the childNodes list of mycel
var objSelectedCellText = objTD.childNodes[0];
// get the data
alert(objSelectedCellText.data);
}
// Sets the selected index to which ever row that has been selected via a mouse over event
function SetSelectIndex(nIndex)
{
var objTable = document.getElementById("recordTab1");
if (objTable)
{
var nMaxRows = getMaxRowsInTable();
if (gnSelectedIndex >= nMaxRows)
{
var objTR = objTable.getElementsByTagName("tr")[nMaxRows-1];
}
else
{
var objTR = objTable.getElementsByTagName("tr")[gnSelectedIndex];
}
objTR.style.background="#deebde";
gnSelectedIndex = nIndex;
gnCurrentTableRowCellValue = nIndex;
}
}
// function that works out the maximum number of rows returned currently in the table of stock lists
function getMaxRowsInTable()
{
var objTable = document.getElementById("recordTab1");
if (objTable)
{
var nLocalIndex = 0;
var obj = objTable.getElementsByTagName("tr")[nLocalIndex];
while(obj != undefined)
{
nLocalIndex++;
obj = objTable.getElementsByTagName("tr")[nLocalIndex];
}
return nLocalIndex;
}
else
{
return 0;
}
}
// End of Stock lookup section
///////////////////////
</script>
<style type="text/css">
td.content_TC_td_a {
font-size: x-small;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<input type="text" id="txtStockQuote" size="30" style="display:none" onkeyup="showResult();" />
<div id="livesearch" class="xStockLookup" style="width:480px;background-color:#deebde;display:none;position:absolute;left:363px;top:1092px;"></div>
Thursday, 5 December 2013
Simple Adaptation of Flyout Code that uses a List's item as its content for the flyout
This summary is not available. Please
click here to view the post.
Subscribe to:
Posts (Atom)