I'm trying to use IE ActiveX control to update Autohotkey GUI dynamically, but encountering weird behavior. Please help.
; ie-refresh.ahk on Autohotkey 1.1.24
global WB
Gui, Font, s9 cBlack, Tahoma
Gui, Add, Text, , % "Click button to see html content."
Gui, Add, ActiveX, xm w120 h30 vWB, Shell.Explorer
Gui, Add, Button, xm gBtnClicked, % "Update html text"
Gui Show
return
BtnClicked()
{
html_tmpl =
( Ltrim Join
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0px;
color: red;
}
</style>
</head>
<body>
Count: {}
</body>
</html>
)
static snum := 0
snum++
html_code := Format(html_tmpl, snum)
WB.Navigate("about:blank")
WB.document.write(html_code)
}
GuiEscape:
GuiClose:
ExitApp
When I click the button, the IE content updates, but it only updates twice.
On third button click, IE content area almost certainly shows as blank.
Keep clicking the button, the red text appears intermittently and randomly, rougly one out of ten clicks.
So what's wrong with my code?
The problem seems to be with calling navigate the second time.
I thought that WB.Stop() would fix the problem but after that you find out that WB.Navigate is not enough to clean the screen so...
The most sensible alternative looks like putting the WB.Navigate after the gui-add (or somewhere after) and then using WB.Refresh() .
Just for refrerence, some WebBrowser Control documentation here.
Although I cannot explain the weird behavior in my question, I have managed to find out a solution to my requirement.
Use code below:
; ie-refresh.ahk on Autohotkey 1.1.24
global WB
Gui, Font, s9 cBlack, Tahoma
Gui, Add, Text, , % "Click button to see html content."
Gui, Add, ActiveX, xm w120 h30 vWB, Shell.Explorer
Gui, Add, Button, xm gBtnClicked, % "Update html text"
WB.Navigate("about:blank")
Gui Show
return
BtnClicked()
{
html_tmpl =
( Ltrim Join
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0px;
color: red;
}
</style>
</head>
<body>
Count: {}
</body>
</html>
)
static snum := 0
snum++
html_code := Format(html_tmpl, snum)
WB.document.open()
WB.document.write(html_code)
WB.document.close()
}
GuiEscape:
GuiClose:
ExitApp
First, call WB.navigate("about:blank") only once.
Second, when I need to update the whole html document, I need to open + write + close.
Now it works reliably.
Related
I have updating results data in four Sheets within a Google Sheets spreadsheet. I want to display the live contents of each sheet in turn on an external display (screen/projector), with an update rate of 10 to 15 seconds between each change of sheet. I've been unable to find any complete solution to this.
Things I've looked at:
Copy the data from each page into Google Slides, maintaining live data update. Then publish the four slides, specifying a refresh rate. This works, but it doesn't update the Slides publication when data in the source Sheets changes. You have to go into Slides and do a manual refresh. Then you also have to refresh the webpage displaying the published slides. It does work, but I really want the displays to update as soon as data in the Sheets are updated.
Display the Google Sheets themselves, with a mechanism to select each sheet in turn every 10 seconds. This felt do-able, with a bit of AppsScript Java I can select individual sheets. Issues with this are I've been unable to resolve are the the minimum timer for a trigger is 1 minute, and I've been unable to get a Triggered function to select the sheets. I think the context for a Trigger may prevent this working.
Use 'something else' to extract the data from the Google Sheet, and create the live updating displays. I've been unable to find anything that would do this. I suspect someone with much better web coding than mine could achieve it, but I'm trying not to get too complicated.
Any suggestions greatfully received.
You can create a local HTML file, show the spreadsheet inside an iframe and change the iframe-URL to the next
sheet every 15 seconds. This way, instead of using GAS triggers, the page gets updated using local JavaScript, so
you dont have to wait 1 minute.
Save the next code as an HTML file.
Update the spreadsheetUrl and sheetIds variables
Open the file in a browser (I recommend Firefox)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<iframe id="iframe1" src="" style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"> Your browser doesn't support iframes
</iframe>
</body>
<script>
var spreadsheetUrl = "https://docs.google.com/spreadsheets/d/123/edit#gid=";
var sheetIds = ["12345", "23456", "34567", "45678"];
var currentSheet = 0; //0-3
var myIframe = document.getElementById("iframe1");
// Initializes iframe
myIframe.src = spreadsheetUrl + sheetIds[currentSheet];
// Updates iframe very 10,000 milliseconds
setInterval(function() {
// Increases sheet
currentSheet++;
// If 4th sheet has been shown, then go back to 1st sheet
if (currentSheet > 3)
currentSheet = 0;
// Updates iframe
myIframe.src = spreadsheetUrl + sheetIds[currentSheet];
}, 10000);
</script>
</html>
can somebody help me to solve this prob :
I've a page width some div ID (Section of page #1 #2 ...) and a link (NEXT), how i can do to increase this link each time the user click on without refreshing the page ?
sample if link was 1 .. link become 2 etc ..
Any ideas ?
AJAX if you need to pull data from the server again on the click.
Standard JavaScript if you just want to do the number increment locally in the browser without anything fancy.
I would use an ajax for that just to send a request to php script what would generate a whole <a> tag and insert it in html. So onload of the page you set counter on 1 for example and everytime you click the 'next' you trigger onclick event (call a function on this event) increase your counter by 1 and send this value to server where script is generating for you tag or something similar... add it to the html, so you can update your link in html without refreshing the page. On parallel you can delete, hide or show other elements if you need.
I hope that will give you some idea. I would tell you more if i would be able to see your code, so far it is as i see your situation. Sorry if i didn't get it right; )
<html>
<head>
<style>
div {
display: block;
width: 100px;
height: 800px;
background-color: red;
}
a {
font-size: 3em;
position:fixed;
top: 0;
right:0;
}
</style>
</head>
<body>
<div id="section1">one</div>
<div id="section2">two</div>
<div id="section3">three</div>
next
<script>
var i = 1;
function increaseLink() {
i++;
var link = document.getElementById("linkId");
link.innerHTML = "click";
link.setAttribute('href', "#section"+ i);
return false;
}
</script>
</body>
</html>
Is that what you need? You do not need php or ajax to achieve this.
In the browser script: Listen onClick event on links and send AJAX-request to php-script when links is clicked.
In the server script: Update field on database or other storage.
I've got a presentation running with reveal.js and everything is working. I am writing some sample code and highlight.js is working well within my presentation. But, I want to incrementally display code. E.g., imagine that I'm explaining a function to you, and I show you the first step, and then want to show the subsequent steps. Normally, I would use fragments to incrementally display items, but it's not working in a code block.
So I have something like this:
<pre><code>
def python_function()
<span class="fragment">display this first</span>
<span class="fragment">now display this</span>
</code></pre>
But the <span> elements are getting syntax-highlighted instead of read as HTML fragments. It looks something like this: http://imgur.com/nK3yNIS
FYI without the <span> elements highlight.js reads this correctly as python, but with the <span>, the language it detects is coffeescript.
Any ideas on how to have fragments inside a code block (or another way to simulate this) would be greatly appreciated.
To make fragments work in code snippets, you can now use the attribute data-noescape with the <code> tag
Source: Reveal.js docs
I got this to work. I had to change the init for the highlight.js dependency:
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() {
[].forEach.call( document.querySelectorAll( '.highlight' ), function( v, i) {
hljs.highlightBlock(v);
});
} },
Then I authored the section this way:
<section>
<h2>Demo</h2>
<pre class="stretch highlight cpp">
#pragma once
void step_one_setup(ofApp* app)
{
auto orbit_points = app-><span class="fragment zoom-in highlight-current-green">orbitPointsFromTimeInPeriod</span>(
app-><span class="fragment zoom-in highlight-current-green">timeInPeriodFromMilliseconds</span>(
app->updates.
<span class="fragment zoom-in highlight-current-green" data->milliseconds</span>()));
}
</pre>
</section>
Results:
I would try to use multiple <pre class="fragment">and change manually .reveal pre to margin: 0 auto; and box-shadow: none; so they will look like one block of code.
OR
Have you tried <code class="fragment">? If you use negative vertical margin to remove space between individual fragments and add the same background to <pre> as <code> has then you get what you want.
Result:
This issue is only with Opera. Other browsers are fine:-
Using JavaScript, I am creating a new window, writing to the document and then calling print and close on the window object.
After the print function executes and the printer selection dialog pops up, if the user clicks "Cancel", the close function executes and the window closes. However, if the user clicks "Print", the document prints however the window does not close.
Here is the JS Fiddle
http://jsfiddle.net/HEaFP/
and here is the code I am using
var ic_hic_demo_window = window.open("", "", "toolbar=no, status=no, directories=no, menubar=no, titlebar=no, location=no, scrollbars=no, resizable=no, height=500, width=500, left=10, top=10");
ic_hic_demo_window.document.open();
ic_hic_demo_window.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><title></title>');
ic_hic_demo_window.document.write('</head><body style="font-family: tahoma, arial, verdana; font-size: 11px" onload="print();close();">');
ic_hic_demo_window.document.write("Some sample text");
ic_hic_demo_window.document.write("</body></html>");
ic_hic_demo_window.document.close();
Any help is greatly appreciated...
Well.. I guess it makes sense to ignore a command to close a window if printing from that window is in progress, don't you? Have you tried to do something like
onload="print();setInterval(function(){close();}, 500)"
the idea being that the script keeps trying to close the window every half a second until it works.
I want to add Google AdWords to my site but the script I'm supposed to add creates an iframe in the dom. This iframe is visible and moves down 13px (its height) all my page.
Is there any way to avoid this? If not, can I hide it without affecting Google AdWords functionality? (It is an empty iframe).
There's an easy fix that doesn't affect the functionality of the code snippet. I've done this with no adverse effects. Just place the script within a hidden div like below and it should do the trick:
<div style="display:none">
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
</div>
#Mario is correct that there is a setting that will allow you to turn this display off. However, this setting doesn't seem to exist on the Google UI for remarketing tags, even though they do display this iframe (I think this is a bug on Google's end, as I imagine the "google_remarketing_only = true" flag was supposed to turn this iframe off and isn't working correctly).
I found out that you can also set this in the tracking JS by manually adding the flag "google_conversion_format = 3", like so:
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 0123456789,
google_conversion_label = "XXXXXXXX",
google_custom_params = window.google_tag_params,
google_remarketing_only = true,
google_conversion_format = 3;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script>
This might be easier that regenerating the tags for some people, and solves the problem in the case that the UI doesn't support setting this option when generating the tags.
I normally add this CSS(3) rule to the stylesheet:
iframe[name=google_conversion_frame]
{
display: none !important;
}
Hope it helps.
you can also set max-height: 0; instead of display:none;
Not sure of implications of display none on the iframe.
This works back to ie6.
iframe[name="google_conversion_frame"] {
display: block;
max-height: 0;
}
The best and simplest solution that I have come across for this issue is simply to remove the frame from the document flow by adding the following code to the css stylesheet:
iframe[name="google_conversion_frame"]{
position:fixed;
}
Hope this helps