I have a jqGrid displaying Tabular data. I have a qTip2 popup window displaying a small window when a user mouses over a hyperlink inside the grid. I'm noticing that an external javascript file is being reloaded every time this popup window displays information. The script is not referenced in the file that is called to display this popup window and would be loaded for the display of the main page.
I see the file being reloaded over and over with this kind of call:
GET http://localhost:4111/Scripts/HelperScript.js?_=1359649163699
GET http://localhost:4111/Scripts/HelperScript.js?_=1359649165768
and so on...
Can someone put me on the path of why this is happening?
So I just double checked and for some reason I had a call in the code that was being loaded to present the popup window that would also reference my script file.
<script src="#Url.Content("~/Scripts/HelperScript.js")" type="text/javascript"></script>
I"m assuming since it was trying to load two copies of the same Javascript file that it was loading it again with a random name so as not to conflict? (Removing the above reference from my code has stopped the script from being loaded again)
Related
I have a user control, which contains a bunch of javascript code.
At the beginning of my javascript code, I've put a simple console.log('test') to see whether my javascript code has been loaded.
If I add my user control to a page, it displays its content correctly, and the test log message also appears in the browser's developer console.
However, if I put my user control in an ASP:Panel, that has Visible=false set by default, and I set its Visible property later, then the panel and the user control in it shows up correctly, but the related javascript code does not load in. Neither the methods in it are not callable when I try to call via ScriptManager.RegisterStartupScript, nor the "test" log message is displayed in the console.
Any suggestions on what could I try to force my Javascript to load when the User Control is loaded and displayed later?
Alright, I've found the issue.
My control was in an Update Panel that prevented my javascript to load in.
After I added a PostBackTrigger to my update panel to the other control that also made my asp:Panel visible, then it forced a full page load, and my user control's javascript code also loaded correctly.
I'm trying to add the Facebook Pixel script to a specific page (X) of my Next js application.
I'm using next/script to add it and it is loaded properly only when page X is accessed.
However, whenever I navigate to another page after accessing page X and after the script is loaded, the script remains in the Devtools. My question is: is it supposed to work that way? Is Next.js just optimizing the script load and only executing it when page X is loaded/being accessed and nowhere else or should I explicitly tell it to remove the script if the page path is different?
I'm using the inline script approach (with the default loading strategy of next/script):
<Script id="Facebook_Pixel_Code">
{`!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, document,'script','https://connect.facebook.net/en_US/fbevents.js');fbq('init', [OUR_FB_ID]);fbq('track', 'PageView');`}
</Script>
background: i have a page in my web app with an iframe in it that displays a pdf file.
I require a browser's print preview window to appear as soon as this page in my web app loads. The print preview window will contain the contents of the iframe and print it.
Currently, i bind a function on the iframe's load event as follows:
$('#iframe').load(function () {
$("#iframe").get(0).contentWindow.print();
});
This works fine when i debug locally. However when i upload to server, the print preview screen will not automatically popup. In fact i have to first click on a button or element for it appear. Is there a way around this?
Thanks in advance..
Try this,
window.frames['#iframe'].focus();
window.frames['#iframe'].print();
Numerous methods using either jQuery or plain javascript did not fix the issue. However, after i set a 1 second delay to the print function, it worked!
setTimeout(function () {
$("#iframe").get(0).contentWindow.print();
}, 1000);
I suppose it has something to do with the server. It probably needs extra time to process the pdf in the iframe
well I got a (jquery) javascript in .js loading inside a template in grails , the first time it loads in the template, and the script works perfectly, but once I hit the button to change the content in the template , the javascript doesn't reload, but once I embedded javascript directly in the template it loads fine, but once I put it back in a .js it doesn't load again. any suggestion?
it works this way:
<g:javascript>
code code
</g:javascript>
but doesn't work again if I use this:
<script src="${resource(dir:'js',file:'hoverInfo.js')}" type="text/javascript" charset="utf-8"></script>
once I hit the button to change the content in the template...
do you reload the full page or just a portion via remoteLink/ajax?
I guess in the second case, the browser notices that it already loaded the js-source and will not reload it - hence will not execute it a second time...
I guess you will have to use the onSuccess event to execute the script a second time...
Double check the location of the javascript source file, which can be different when loading the page. Therefore go in to the network tab of your firebug and check, whether the browser tells you 404, when pressing your ajax-button.
I am embedding a dynamic webpage in a popup. Currently its working and every time popup is loaded the webpage is loaded again, thus me losing the work i did on the webpage in popup. Though its fine, but i want that webpage remain loaded in background and i just show it in popup on click. to do this i copied complete code from my pop up page(script+html) to background.html. Now how should i access the page completely in popup and show directly(i want to show html also-from background page)
Thanks
Popups live in the same process (the extension process) as the background page, and one page can get the DOM Window of the other. A popup gets the background page by calling chrome.extension.getBackgroundPage(). So every time you open the popup, just read and write to some variable on the background page, for example chrome.extension.getBackgroundPage().enteredData = "value";.
Alternately, you can use HTML5 localStorage to store variables even after the browser is shut down; e.g. localStorage['enteredData'] = "value".