Is it possible to display a website (eg. www.google.com ) using iframe in the sidebar of google docs while developing using app-script iframe .'X-Frame-Options' to 'same-origin' , error is occurring . I tried setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
Still the same error occurs.
Screenshot Link
Click this link for screenshot of error
===========
Code.gs
function onInstall(e) {
onOpen(e);
}
function onOpen(e){
var ui = DocumentApp.getUi();
ui.createMenu("IframeOptions").addItem("iFrame",'sviFrame').addToUi();
}
function sviFrame(){
var iframe = HtmlService.createHtmlOutputFromFile('Iframe').setSandboxMode(HtmlService.SandboxMode.IFRAME).setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
/*var template = HtmlService.createTemplateFromFile('Iframe')
.evaluate()
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);*/
DocumentApp.getUi().showSidebar(iframe);
}
=============
Iframe.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<iframe src="https://www.google.com" height="1500" width="100%"></iframe>
</body>
<script>
alert(google.script.sandbox.mode);
</script>
</html>
Related
I got error in below code...
<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Access-Control-Allow-Origin" CONTENT="https://www.abcd.xyz">
</head>
<body bgcolor="#282c34" text="#43a199" >
<iframe src="2739.pdf#zoom=Fit" id="ifrmCast" type="application/pdf" width="100%" style="height:95vh;"></iframe>
<button onclick="ifrmLoad();"> Click Mee... </button>
<script>
function ifrmLoad() {
alert("called");
var iframe = document.getElementById("ifrmCast");
var elmnt = iframe.contentWindow.document.getElementsByClassName("canvasWrapper");
elmnt.style.display = "none";
alert(elmnt.innerHTML);
}
</script>
</body>
</html>
No Any Solution found here...
I Tried..
< META HTTP-EQUIV="Access-Control-Allow-Origin" CONTENT="https://www.acd.xyz" >
about:config ( Firefox )
YQL
and so many etc..
i have a code that is just basically showing stars i want that to be added to my wordpress website i have successful uploaded and linked the css and js files in header.php and when i run any page it is infact loading the files i know due to security concerns wordpress wont let you add script in its editor what is the solution? here's my html and js code
<!DOCTYPE html>
<html lang="en">
<head>
<title>RateYo - Scratchpad</title>
<meta charset="utf-8"></meta>
<link rel="stylesheet" href="jquery.rateyo.min.css"/>
</head>
<body>
<div>
<div id="rateYo1" style="margin: 10px"></div>
</div>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.rateyo.min.js"></script>
<script>
$(function () {
$("#rateYo1").rateYo({
rating: 3.5,
readOnly: true
});
});
</script>
</body>
</html>
You can easily add anything you like via hooks.
add_action( 'wp_footer', 'my_custom_scripts', 500 );
function my_custom_scripts() { ?>
<script type="text/javascript">
(function ($, document, undefined) {
// Your custom code goes here.
}(jQuery, document))
</script><?php
}
Alternatively you could add it to the head as well using:
add_action( 'wp_footer', 'my_custom_scripts', 500 );
I'm creating extension using crossrider. In this extension I want to open a new tab with html from resources. Its opening page in new tab without issues. Now I want to add js & css to that, that to available in resources. Kindly help in adding css & js.
code in background.js
appAPI.openURL({
resourcePath: "troubleShooter.html",
where: "tab",
focus: true
});
in troubleShooter.html
<html>
<head>
<link media="all" rel="stylesheet" type="text/css" href="css/ie.css" />
<script type="text/javascript" src="js/ie.js"></script>
</head>
<body>
</body>
</html>
Crossrider recently introduced the ability to open a new tab with HTML from resources. However, such pages cannot directly access other resource file using link and script tags embedded in the HTML.
Though in it's early release, one of the features of the HTML page is the crossriderMain function that runs once the page is ready. In this early release, the function supports the following Crossrider APIs: appAPI.db.async, appAPI.message, and appAPI.request.
Hence, even though in this early release there isn't a direct method to add resource CSS & script files to the resource HTML page, you can workaround the issue by loading the resources into the asynchronous local database and applying it to the HTML page using standard jQuery. For example:
background.js:
appAPI.ready(function() {
// load resource file 'style.css' in to local database
appAPI.db.async.set('style-css', appAPI.resources.get('style.css'));
// load resource file 'script.js' in to local database
appAPI.db.async.set('script-js', appAPI.resources.get('script.js'));
// open resource html
appAPI.openURL({
resourcePath: "troubleShooter.html",
where: "tab",
focus: true
});
});
troubleShooter.html:
<!DOCTYPE html>
<html>
<head>
<!-- This meta tag is relevant only for IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript">
function crossriderMain($) {
appAPI.db.async.get('style-css', function(rules) {
$('<style type="text/css">').text(rules).appendTo('head');
});
appAPI.db.async.get('script-js', function(code) {
// runs in the context of the extension
$.globalEval(code.replace('CONTEXT','EXTN'));
// Alternatively, run in context of page DOM
$('<script type="text/javascript">')
.html(code.replace('CONTEXT','PAGE DOM')).appendTo('head');
});
}
</script>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
style.css:
h1 {color:red;}
script.js
console.log('CONTEXT:: script.js running');
Disclaimer: I am a Crossrider employee
Copied a script below from a tutorial and ran it.
I got a blank screen and a message that said "Done, but with error in page."
Think the line with the error is the one that says
google.maps.event.addDomListener(window,'load',initialize);
there's no error when it's commented out.
What am I doing wrong?
<!DOCTYPE html>
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?key=HERE I PUT THE API KEY WITH NO QUOTES&sensor=false">
</script>
<script>
function initialize()
{
var mapProp={
center:new google.maps.LatLng(51.508742,-0.120850),zoom:5,mapTypeID:google.maps.MaptypeID.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window,'load',initialize);
</script>
<title>
</title>
</head>
<body>
<div id="googleMap" style="width:500px;height:380px;">
</div>
</body>
</html>
Try :
mapTypeId: google.maps.MapTypeId.ROADMAP
Note case of "MapTypeId".
Important parts of code:
javascript tinymceplugin:
init : function(ed, url) {
ed.addCommand('addVocabularyLinkCallout', function() {
ed.windowManager.open({
file : ajaxurl + '?action=addvocabularylinkbutton_function',
width : 350 + parseInt(ed.getLang('mytest.delta_width', 0)),
height : 250 + parseInt(ed.getLang('mytest.delta_height', 0)),
inline : 1
}, {
plugin_url : url
});
});
ed.addButton('addvocabularylink', {
title : 'Dodaj link do słowniczka',
cmd : 'addVocabularyLinkCallout',
image : url+'/../img/tinymce/insertpopup.png'
});
},
wordpress ajax support, only for logged in users:
add_action('wp_ajax_addvocabularylinkbutton_function', 'addvocabularylinkbutton_function_callback');
function addvocabularylinkbutton_function_callback() {?>
<!DOCTYPE html>
<head>
<title>Create a Single Link - Button</title>
</head>
<body>
<h2>Test</h2>
</html>
<?php }; ?>
It is not important, that the window doesnt do anything itself, what bothers me is "0" at end of the code of the popup window:
<!DOCTYPE html>
<head>
<title>Create a Single Link - Button</title>
</head>
<body>
<h2>Test</h2>
</html>
0
How to get rid of it?
After digging here and there, I have found, that it is not a problem of TinyMCE, but wp_ajax callout. It needs:
die;
at the end.
So the correct code would be:
add_action('wp_ajax_addvocabularylinkbutton_function', 'addvocabularylinkbutton_function_callback');
function addvocabularylinkbutton_function_callback() {?>
<!DOCTYPE html>
<head>
<title>Create a Single Link - Button</title>
</head>
<body>
<h2>Test</h2>
</html>
<?php
die;
};
?>