fire fox stuck on transferring data from server - javascript

I'm opening new tab by click on button in the home page , and building the new tab from copying some Elements from the home page,on loading event,i do all my work , also I'm changing image src on load event by filling it from the server , i don't know why fire fox stuck on status of "Transferring data from server",can any one help me in this problem?
this is piece of my code:
window.onload = function () {
document.getElementById('demo_tab_info').innerHTML=opener.document.getElementById('demo_tab_ifo').innerHTML;
if(document.getElementById("Have_Patient__Photo_image" ).value =='true')
{
document.getElementById("pat_<%=Pat_Acct%>_pic_area").innerHTML="<img name='pat_<%=Pat_Acct%>_pic_image' id='pat_<%=Pat_Acct%>_pic_image' src='' onload=\"Fix_Dimensions('pat_<%=Pat_Acct%>_pic')\"/>";
var Image_Element_Name = 'pat_<%=Pat_Acct%>_pic_image';
var Image = document.getElementById(Image_Element_Name);
Image.src='/jspapps/apps/file_uploader/view_image.jsp?table=pat_dri_images&db=admin&im_type=pat_pic&pat_acc=<%=Pat_Acct%>&ts='+(new Date()).getTime();
}
}

Install Firebug and use the "Net" tab to see which connections are made and which one is kept open.

Related

Opening new tab with python Selenium (via javascript) suddenly stopped working

The Situation
I have this code below, which was working perfectly many many times the way it is, then all of a sudden it stopped working when it gets to the step of opening a new tab via javascript.
url = 'https://website'
opt = Options()
opt.add_argument('--start-maximized')
opt.add_argument("disable-infobars")
opt.add_experimental_option("detach", True)
service = Service(r'C:\Users\chromedriver_new.exe')
driver = webdriver.Chrome(options= opt,service = service)
login(url) ###function that opens the url and passes user/keyword - up to this part it's working perfectly
img_url = "https://website/" + url[30:55] + "/img.jpg" ##source of image I want to download
#The problem starts here, I've printed the img_url and I can open it fine in my navigator, but when I run the code it just stops here and never opens the new tab
#I've already tried changing the javascript by passing "+img_url+" directly
#I've also tried already to open a blank new tab and even this is not working
driver.execute_script('window.open(arguments[0],"_blank");',img_url) ###open link in new tab
time.sleep(2)
driver.switch_to.window(driver.window_handles[1]) ##change focus to new tab
time.sleep(2)
img_url_full = driver.find_element(By.XPATH,"/html/body/img").get_attribute("src") ##it gets the full path to the image, which includes a valid token that enables me to access (if I would try to downlaod the img_url directly it wouldn't work)
time.sleep(2)
urllib.request.urlretrieve(img_url_full,name) ##download image
Extra Information
I don't know if that has something to do with it, but usually my browser would always stay open unless I closed it manually (there is no close/quit on the code), but around the same time that the new tab stopped to work the browser started to close automatically right after the step of login - to avoid that I then had to add the
opt.add_experimental_option("detach", True)
(which is working).
The Question
Why is this happening and how could i debug this?

Document.selector.innerHTML only works after refreshing the page

I am trying to get some information from innerHTML from Youtube source page.
However, when I do this
var myStr = document.getElementById('player').innerHTML;
alert(myStr);
this only procs the alert if I visit the same Youtube page twice. If I navigate to a different video, no alert shows up, unless I refresh the page again.
I am also doing this:
if(document.readyState === 'loading') {
document.addEventListener("load", searchSomething, false);
} else {
searchSomething();
}
at the beginning of the Javscript just to make sure that I am getting the innerHTML after the whole page loads. What is the problem here? How do I fix this so that I do not have to refresh the page to proc the alert!
UPDATE ----------------------
I started to log every event that gets fired on Youtube.
However, Youtube does not fire any events including "load", "unload", "hashchange". It only fires Javascript events if you refresh the page!!!
How can this be possible?
If you use jquery it will be like this
$(document).ready(function() {
var myStr = document.getElementById('player').innerHTML;
alert(myStr);
}

Updating Angular 1.2.10 to latest with a minor bug (Overriding a href - third party)

What I did,
I took this angularjs project and did nothing just updated it using nugget package manager to latest angular libraries,
https://github.com/OfficeDev/Learning-Path-Manager-Code-Sample
Issue
When I click on top right settings button, "Working On It" dialog appears and doesn't goes away.
What I investigated
Looking at url, when I click on "cog" url changes from,
https://omapny-ersda819baad8d.apps.com/sites/Dev1/lpm/app.html#/
to
https://omapny-ersda819baad8d.apps.com/sites/Dev1/lpm/app.html#
and dialog appears, but when I add "/" again, dialog disappears
what could be wrong ? I am totally new to AngualrJS
Edit
Most likely because it has this third party link,
<a id="chromeControl_topheader_apptitlelink" href="#" class="ms-core-suiteLink-a" target="_top"><span id="chromeControl_topheader_apptitle">Learning Path Manager</span></a>
How to get around this ?
I fixed this issue by doing followings,
for app title, I had to modify appStartPage to following,
function init() {
// create chrome control settings
spChromeControlData = {
appStartPage: "app.html#/",
Above change is in spAppChrome.js controller file then in same file i added this within init function,
//fix issues with chrome ctrl
$('body').on('click', '.ms-core-menu-root', function () {
$(this).attr("href", "javascript:;")
});
So this will look something like this,
// create the sharepoint chrome control
var nav = new SP.UI.Controls.Navigation("chrome_ctrl_container", spChromeControlData);
// show chrome control
nav.setVisible(true);
// hide top app chrome (image & app name)
nav.setBottomHeaderVisible(false);
//fix issues with chrome ctrl
$('body').on('click', '.ms-core-menu-root', function () {
$(this).attr("href", "javascript:;")
});
logger.log("spAppChrome loaded", null, controllerId);
common.activateController([], controllerId);
}
Let me know if there's any issue.
Thanks

Firefox Add-On SDK: Run content script in new tab only once

I am trying to develop a simple add-on for Firefox which should work something like this:
User clicks item in context menu.
New tab is opened.
Content (innerHTML) of the new tab is overridden using content script.
Also, the content script should only be executed once, so that if the user would enter a website in the new tab the script should not be executed.
I've got it working with editing the new tabs content, but my only problem is to have the content script run only once when the tab is opened. In the code I have at the moment the script run every time a page has been loaded in the tab:
var contextMenu = require("sdk/context-menu");
var tabs = require("sdk/tabs");
var menuItem = contextMenu.Item({
label: "Test",
contentScript: 'self.on("click", function () { self.postMessage(); })',
onMessage: function (data) {
newTab();
}
});
function newTab () {
tabs.open("about:blank");
tabs.activeTab.on('ready', function (tab) {
tab.attach({
contentScript: 'document.body.innerHTML = "testing";'
});
});
}
I'm guessing there's a way to have this run only the first time the tab is "ready". Seems like a simple task but I can't figure out how to do this. Anyone got any tips?
Use tabs.activeTab.once(); instead of tabs.activeTab.on();.
This way the listener gets detached once it intercepts the first message.

closing browser within chrome page on test complete

So using TestComplete I'm essentially trying to open up a session on chrome, navigate to a web page, and then click a button on that page. after I'm finished I want to close that browser page. I'm having trouble closing the page though. Here is the code I have so far.
function ChromeTest
{
Browsers.Item(btChrome).Run(MyWebAdress);
var browser = Sys.Browser("chrome");
var page = Sys.Browser("chrome").Page(MyWebAdress);
var MyButton = page.ButtonLocation;
MyButton.click();
browser.BrowserWindow.Close(5000);
}
however, at the Close line I get an error that says "Unable to find the object BrowserWindow". Thanks in advance for any help you have.
Change BrowserWindow to BrowserWindow(0) (or whatever index you see in the Object Browser):
browser.BrowserWindow(0).Close(5000);
Or you can call Close() directly on the Chrome process:
browser.Close(5000);

Categories