Vue v-html : stop executing script inside a iframe rendered - iframe

In vue, v-html won't execute script tags. But if we place a iframe as the html, and the iframe source is having a script, then it will be executed. Is there anyway we can stop this?

Related

Reusable jquery dialog

I am using ASP.NET 3.5 with C# 2008.
I want to use a JQuery dialog for showing error message.
For this I need to include a CSS, a JavaScript file into aspx page. Also have to create a <div> with specific Id or class and have to put some buttons like OK, Cancel inside it. Also have to put a label inside <div>. And have to create a <script> block which contains functions to Open or Close the dialog.
All this working fine in single aspx page. But now I want to use this across all the pages and also don't want to make repetitive codes.
So what will be the best way to implement it? Should I put all these stuff inside a user-control and import it into every aspx page where I want to use that dialog? Or any other best way to achieve this?
You can put your javascript code into a js file and add the reference of that js file into your master page then you can call the jquery error dialog into your application.

JQuery not working on redirection

I have an iframe within div
<div>
<iframe pageB>
</div>
on button click in iframe, redirected to a different page A - I have a jquery to hide the div on page load of A - so this part of jquery is not working - normal alert window on this page load works - I saw $ undefined - included jquery exclusively on pageA but still undefined error has gone but jquery does not work - can any body shed some light on this? doesnt jquery work in this redirection scenario.
If the IFRAME is on a different domain than the DIV this will not work due to security restrictions.
Instead of an IFRAME you could try using jQuery.load() to put the content into your div, and then hide the DIV as a part of the callback to load(). This will only require jQuery to be loaded on your main page.

jQuery undefined in content page when using master pages which has jQuery reference

I have a nested master page. A parent master page, a child master page and a content page whose master page is the child master page. I have a reference to jQuery in the parent master page in the head section.<script type="text/javascript" src='<%#ResolveUrl("~/includes/jquery-1.4.2.min.js") %>' ></script> & Page.Header.DataBind(); in the OnLoad event.
I am using jQuery in all the pages including the master pages. However I am getting "Error: $().ready is not a function" in the content page. If I include jQuery reference in the content page it works.
Question: If the reference to jQuery is in the master page head section, why aren't the content pages able to use jQuery? When I do view source, the script tag with jQuery is there and it works.
The master pages and content page are merged during rendering and sent to the browser as a single html page so I am not sure when master pages are used, jQuery references break.
UPDATE:
When I changed '$.ready(function()' to 'jQuery(document).ready(function($)' it worked! I am not loading any other javascript libraries and I am not using MS Ajax.
First, and I didn't notice this before, but is your original call to $.ready(function() {}), which didn't work, but jQuery(document).ready(function() {}) did work? Does your call work if you use $(document).ready(function () {} )? Just wanted to make sure it's not a typo. The jQuery docs say the $.ready(function() {}) is valid, but it's not recommended.
OK, assuming it's not a typo, it definitely sounds like you have a conflict with the '$' variable. If you're using third-party controls or ASP.NET AJAX, you may run into conflicts (even though you may not be including the JS file explicitly).
If you could post what gets output by the browser after your page loads, that would help.
Also, if you run Fiddler (or some other traffic request tool), you can see if any JS references are being downloaded. Look not only for .JS files, but also .AXD files (some third-party tools name these files ScriptResource.axd or WebResource.axd, and they may redefine the '$' variable).
You may want to check out this link on the jQuery API page about the noConflict function. This helps when you have a conflict with the $ variable.
Without seeing the output, it's tough to diagnose. But hopefully this helps.
i also have the same issue, it sounds like a jQuery conflict
i fixed my issue :
<script type="text/javascript" >
$(document).ready(function () {
$.noConflict();
});
</script>
in the <head> section

Jquery accordion does not work when I put the script in script file on a master page, but it does when I put it directly on the page

I have a page called Default.aspx which inherits from a master page called Main.master.
In Main.master, I have a asp:ScriptManager and within the script manager, I put the jQuery 1.4 library, jquery 1.7.2 ui library, I also put a custom js file I created which for now just has the code:
$("#accordion").accordion({
collapsible: true,
autoHeight: false
});
When I load default.aspx, it is loading all the javascript files, but the accordion div is not being rendered into an accordion. If I put the code above directly between script tags on default.aspx, the accordion renders, so I am assuming it has something to do with it not recognizing the accordion id, but correct me if I am wrong.
Im goign to guess your DOM isnt ready when you call the accordian in the external file but it is when you call it in the script tags. did you wrap it in $(document).ready(function(){});?
I have the exact same problem with jQuery 1.4 and accordion. I have a hidden pane, and when I show that pane it's not an accordion... and yes, I have the call to the accordion inside $(document).ready(function(){});
My solution was to call the accordion every time I show the hidden pane, but that seems overambitious.
Cheers

How to Add script codes before the </body> tag ASP.NET

Heres the problem,
In Masterpage, the google analytics code were pasted before the end of body tag.
In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript and put it before the end of body tag, because this script uses the google analytics variables.
How can i achieve this?
An inelegant but simple approach, if you're able to avoid using ClientScript, would be to just stick a literal in the page where you want your script to be rendered and put the script in there from your codebehind (i.e. myLiteral.Text = "client script";).
Take a look at RegisterStartupScript
The script block will be placed right above the </form> tag at the end of the page.
You could delay your script execution until after the page loads, then it won't matter where your script resides.

Resources