I'm trying to upload a mraid project to Google's DoubleClick studio and notice the mraid.expand() event is not working properly. The ad is meant to be an in-app expandable banner, and basically after the very first time, mraid.expand() will not actually expand to full screen but rather expand to within the banner itself. The solution right now is this:
var isFirstTime = true;
...
if(isFirstTime) {
mraid.expand();
isFirstTime = false;
} else {
mraid.expand();
if (window.parent) window.parent.mraid.expand();
}
I noticed that because DoubleClick embeds everything into layers of , the closing button is actually in the parent of the containing the code we uploaded, thus a window.parent.mraid.expand() is needed to trigger the expand() properly. This seem really hacky, and I'm wondering if anyone has seen this issue before or has a better solution.
Keep in mind that MRAID format was deprecated from DoubleCLick Studio, it is required to build Mobile-friendly Studio HTML5 format instead.
Related
I'm using Wordpress Visual Composer and would like a button to have a smooth scroll down to a specific section on the same page.
I've explored the standard button element's "insert inline onclick javascript action" with anchor IDs and code from many other similar Q&As, but have had no luck. Does anyone have the answer specifically to Wordpress Visual Composer?
(Below are screenshots of how I tried to implement #Frits suggestion.)
Button href
Raw JS block
In future, adding your current attempt is a great idea as it will help us adjust your code. You've clearly tried some things, they clearly didn't work (else you wouldn't have come here) - show us what you tried, and we might be able to help you fix your current attempt!
Anyways, on to the actual code.
Seeing as you are missing a bit of information, I am going to have to make a few assumptions.
I am going to assuming that you have a button that looks like this:
Click here to scroll down
and I am going to assume that you have given your visual composer row an ID of my-visual-composer-row-id (you can do this under the edit options on the actual row itself)
If you're ok with using jQuery, you can then implement the following either in a RAW JavaScript block somewhere (preferably the bottom of the page), or if you're making your own theme, you can add this to your .js file.
jQuery(document).ready(function($){
$('.my-link, .my-link a').click(function(e){
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = jQuery(this.hash);
target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
if (target.length) {
jQuery('html, body').animate({
scrollTop: Math.ceil(target.offset().top)
}, 1000);
return false;
}
}
});
});
this has been adapted from the CSS-Tricks smooth scrolling solution which can be found here.
I realise this is quite an old post but this just worked for me...
To achieve this in Visual Composer frontend editor, add your anchor id to the Anchor field for the row you want to jump to.
In the Row Setting dialogue, under the Anchor text field you can see a hint that says:
'If anchor is "contact", use "#!/contact" as its smooth scroll link.'
e.g http://domainname.com/page-name/#!/contact
Hope that helps,
Ben
So I would like to be able to have a print button for entries in our database so users can print an entry via a print friendly "form".
My thought was to create a separate page, add labels and have those labels pull the relevant information.
I know I can add the open widget information via this code:
app.datasources.ModelName.selectKey(widget.datasource.item._key);
app.showPage(app.pages.TestPrint);
But I'm running into a few problems:
I can't get the page to open in a new window. Is this possible?
window.open(app.pages.TestPrint);
Just gives me a blank page. Does the browser lose the widget source once the new window opens?
I can't get the print option (either onClick or onDataLoad) to print JUST the image (or widget). I run
window.print();
And it includes headers + scroll bars. Do I need to be running a client side script instead?
Any help would be appreciated. Thank you!
To get exactly what you'd want you'd have to do a lot of work.
Here is my suggested, simpler answer:
Don't open up a new tab. If you use showPage like you mention, and provide a "back" button on the page to go back to where you were, you'll get pretty much everything you need. If you don't want the back to show up when you print, then you can setVisibility(false) on the button before you print, then print, then setVisibility(true).
I'll give a quick summary of how you could do this with a new tab, but it's pretty involved so I can't go into details without trying it myself. The basic idea, is you want to open the page with a full URL, just like a user was navigating to it.
You can use #TestPrint to indicate which page you want to load. You also need the URL of your application, which as far as I can remember is only available in a server-side script using the Apps Script method: ScriptApp.getService().getUrl(). On top of this, you'll probably need to pass in the key so that your page knows what data to load.
So given this, you need to assemble a url by calling a server script, then appending the key property to it. In the end you want a url something like:
https://www.script.google.com/yourappaddress#TestPage?key=keyOfYourModel.
Then on TestPage you need to read the key, and load data for that key. (You can read the key using google.script.url).
Alternatively, I think there are some tricks you can play by opening a blank window and then writing directly to its DOM, but I've never tried that, and since Apps Script runs inside an iframe I'm not sure if it's possible. If I get a chance I'll play with it and update this answer, but for your own reference you could look here: create html page and print to new tab in javascript
I'm imagining something like that, except that your page an write it's html content. Something like:
var winPrint = window.open('', '_blank', 'left=0,top=0,width=800,height=600,toolbar=0,scrollbars=0,status=0');
winPrint.document.write(app.pages.TestPage.getElement().innerHTML);
winPrint.document.close();
winPrint.focus();
winPrint.print();
winPrint.close();
Hope one of those three options helps :)
So here is what I ended up doing. It isn't elegant, but it works.
I added a Print Button to a Page Fragment that pops up when a user edits a database entry.
Database Edit Button code:
app.datasources.ModelName.selectKey(widget.datasource.item._key);
app.showDialog(app.pageFragments.FragmentName);
That Print Button goes to a different (full) Page and closes the Fragment.
Print Button Code:
app.datasources.ModelName.selectKey(widget.datasource.item._key);
app.showPage(app.pages.ModelName_Print);
app.closeDialog();
I made sure to make the new Print Page was small enough so that Chrome fits it properly into a 8.5 x 11" page (728x975).
I then created a Panel that fills the page and populated the page with Labels
#datasource.item.FieldName
I then put the following into the onDataLoad for the Panel
window.print();
So now when the user presses the Print Button in the Fragment they are taken to this new page and after the data loads they automatically get a print dialog.
The only downside is that after printing the user has to use a back button I added to return to the database page.
1.
As far as I know, you cannot combine window.open with app.pages.*, because
window.open would require url parameter at least, while app.pages.* is essentially an internal routing mechanism provided by App Maker, and it returns page object back, suitable for for switching between pages, or opening dialogs.
2.
You would probably need to style your page first, so like it includes things you would like to have printed out. To do so please use #media print
ex: We have a button on the page and would like to hide it from print page
#media print {
.app-NewPage-Button1 {
display : none;
}
}
Hope it helps.
1. Here is how it is done, in a pop up window, without messing up the current page (client script):
function print(widget, title){
var content=widget.getElement().innerHTML;
var win = window.open('', 'printWindow', 'height=600,width=800');
win.document.write('<head><title>'+title+'/title></head>');
win.document.write('<body>'+content+'</body>');
win.document.close();
win.focus();
win.print();
win.close();
}
and the onclick handler for the button is:
print(widget.root.descendants.PageFragment1, 'test');
In this example, PageFragment1 is a page fragment on the current page, hidden by adding a style with namehidden with definition .hidden{display:none;} (this is different than visible which in App Maker seems to remove the item from the DOM). Works perfectly...
2. You cannot open pages from the app in another tab. In principle something like this would do it:
var w=window.parent.parent;
w.open(w.location.protocol+'//'+w.location.host+w.location.pathname+'#PrintPage', '_blank');
But since the app is running in frame nested two deep from the launching page, and with a different origin, you will not be able to access the url that you need (the above code results in a cross origin frame access error). So you would have to hard code the URL, which changes at deployment, so it gets ugly very fast. Not that you want to anyway, the load time of an app should discourage you from wanting to do that anyway.
I'm using ssrs with an asp.net reportviewer control to display server reports. We want to do away with the toolbar because it doesn't fit with our look and feel but we want to maintain some of the functionality, the one bit I'm struggling with is the print. Is there any way to bring up the same print dialog as the print button on that toolbar from the asp.net page?
http://msdn.microsoft.com/en-us/library/ms252091(v=VS.80).aspx
Is the closest that I’ve found, however I’m not using local reports (so it would make sense if there was a built in function around somewhere), and it skips the printer dialog portion which is unacceptable. I don’t believe that I can actually call the winforms printdialog on an asp.net page, but it’s not something I’ve tried.
Any help would be much appreciated.
Here is a script to bring up the print dialog:
<script language="javascript">
function PrintReport() {
var viewerReference = $find("ReportViewer1");
var stillonLoadState = clientViewer.get_isLoading();
if (!stillonLoadState ) {
var reportArea = viewerReference .get_reportAreaContentType();
if (reportArea == Microsoft.Reporting.WebFormsClient.ReportAreaContent.ReportPage) {
$find("ReportViewer1").invokePrintDialog();
}
}
}
</script>
To invoke, just call PrintReport()
Detailed explanation here:
http://blogs.msdn.com/b/selvar/archive/2011/04/09/invoking-the-print-dialog-for-report-viewer-2010-control-using-the-javascript-api.aspx
I would like to open a document after my ASP.NET page loads in a separate window. I would like to do this with the document not attempt to be blocked by a pop-up blocked. I tried and I am getting the prompt to ask if I would like to allow the popup. Is the best way to do this using a timer control or is there a better way in the lifecylce?
I have tried several events, but they are all launching the document prior to page load.
Fundamentally what you're trying to do is exactly the thing that pop-up blockers are designed to prevent - load a pop-up window without an explicit user interaction. There may be various tricks you could use to get around certain particular pop-up blockers, but you'll never be able to solve this in the general case.
The best solution is to have a link on your page to open the document in question in a new window. Pop-up blockers do not prevent links targeted to a new window.
I use
function openpage(page) {
if (document.getElementById('hf_open').value == 1) {
openChild(page, 'nueva');
document.getElementById('hf_open').value = 0;
}
}
and in the body onload ="openpage('whateverpage.aspx');"
and in an ASP.NET event I set if I want the popup to be open or not a particular time by setting hf_open to 1 if the pop up has to be opened at that time.
In Internet Explorer 7 with pop up blocker: turn on checked - it works.
How are users getting to your page? You could place the popup JavaScript in the link that takes users to your page.
You could use the onload JavaScript event.
function open_page()
{
popupWin = window.open('windowURL','windowName', ' resizable,dependent,status,width=500,height=400,left=0,top=0')
}
Then have the following body tag
<body onload="open_page()">
However, this won't get around your popup blocking issue.
Thanks to FireFox's buggy implementation of ActiveX components (it really should take an image of them when printing) Flex components (in our case charts) don't print in FX.
They print fine in IE7, even IE6.
We need these charts to print, but they also have dynamic content. I don't really want to draw them again as images when the user prints - the Flex component should do it.
We've found a potential workaround, but unfortunately it doesn't work in FireFox3 (in FireFox2 it sort-of works, but not well enough).
Anyone know a workaround?
Using the ACPrintManager I was able to get firefox 3 to print perfectly!
The one thing I had to add to the example was to check if stage was null, and callLater if the stage was null.
private function initPrint():void {
//if we don't have a stage, wait until the next frame and try again
if ( stage == null ) {
callLater(initPrint);
return;
}
PrintManager.init(stage);
var data:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
data.draw(myDataGrid);
PrintManager.setPrintableContent(data);
}
Thanks. A load of callLater-s added to our custom chart code seems to have done it.