3

I have to add either an embed tag for Firefox or an object tag for Internet Explorer with JavaScript to address the appropriate ActiveX / Plugin depending on the browser. The plugin could be missing and needs to get downloaded in this case. The dynamically added embed tag for Firefox works as expected. The dynamically added object tag for Internet Explorer seems to do nothing at all. The object tag needs the following attributes to function properly.

id ="SomeId" classid = "CLSID:{GUID}" codebase = "http://www.MyActicexSource.com/MyCuteActivex.CAB#Version=2,0,0,1"

Even a general working idea or method would be nice.

Thanks!


NHibernate: One base class, several mappings

I'm relatively new to NHibernate, but have been using it for the last few programs and I'm in love. I've come to a situation where I need to aggregate data from 4-5 databases into a single database. Specifically it is serial number data. Each database will have its own mapping file, but ultimately the entities all share the same basic structure (Serial class).

I understand NHibernate wants a mapping per class, and so my initial thought was to have a base Serial Class and then inherit from it for each different database and create a unique mapping file (the inherited class would have zero content). This should work great for grabbing all the data and populating the objects. What I would then like to do is save these inherited classes (not sure what the proper term is) to the base class table using the base class mapping.

The problem is I have no idea how to force NHIbernate to use a specific mapping file for an object. Casting the inherited class to the base class does nothing when using 'session.save()' (it complains of no mapping).

Is there a way to explicitly specify which mapping to use? Or is there just some OOP principal I am missing to more specifically cast an inherited class to base class? Or is this idea just a bad one.

All of the inheritance stuff I could find with regards to NHibernate (Chapter 8) doesn't seem to be totally applicable to this function, but I could be wrong (the table-per-concrete-class looks maybe useful, but I can't wrap my head around it totally with regards to how NHibernate figures out what to do).

4

3 に答える 3

13

これと同じことを行う必要があり、OBJECT タグに必要なすべての HTML を JavaScript の文字列に配置し、div タグの innerHTML を OBJECT HTML に置き換えるだけで、IE で問題なく動作します。

// something akin to this:
document.getElementById(myDivId).innerHTML = "<OBJECT id='foo' classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'.....etc";

それはうまくいくはずです、それは私にとってはうまくいきます-私はそれを使ってWindows Media Playerをページに埋め込みます.


更新: ページの読み込みイベントで実行されるか、ユーザーのクリックに応答して実行されるイベント ハンドラーを介して、ページが読み込まれた後に上記のコードを実行します。必要なのは、空の DIV タグまたはその他のタイプのタグを用意することだけです。これにより、その要素のinnerHTMLプロパティを介して HTML コードを挿入できます。


更新: どうやら、私が思っていたよりも多くの助けが必要ですか? たぶんこれが役立ちます:

BODY タグを次のようにします。<body onload="loadAppropriatePlugin()">

これをロードしたいページのどこかに、id「Foo」などの属性を持つ空のDIVタグを配置します。

セクションの<script>タグに次のようなコードを含めます。<head>

function getIEVersion() { // or something like this
   var ua = window.navigator.userAgent;
   var msie = ua.indexOf("MSIE ");
   return ((msie > 0) ? parseInt(ua.substring(msie+5, ua.indexOf(".", msie))) : 0);
}

function loadAppropriatePlugin() {
    if(getIEVersion() != 0) { // this means we are in IE
        document.getElementById("Foo").innerHTML = "<OBJECT id='foo' classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'.....etc";
    } else {
        // if you want to maybe do the same for FF and load that stuff...
    }
}

それは役に立ちますか?

于 2008-11-11T15:55:04.957 に答える
1
var object = document.createelement('object')
object.setAttribute('id','name')
object.setAttribute('clssid','CLSID:{}')

他のパラメータについても同様です。

于 2010-05-03T15:50:44.540 に答える
-5

ふたつのやり方。

1) 必要な場所で document.write を実行するだけです

<script type="text/javascript">
<!--
   document.write("<object id=\"SomeId\" classid=\"CLSID:{GUID}\" codebase=\"http://www.MyActicexSource.com/MyCuteActivex.CAB#Version=2,0,0,1\"></object>");
-->
</script>

2) タグの innerHTML プロパティを編集します。

<div id="my-div"></div>
<script type="text/javascript">
<!--
   document.getElementById("my-div").innerHTML = "<object id=\"SomeId\" classid=\"CLSID:{GUID}\" codebase=\"http://www.MyActicexSource.com/MyCuteActivex.CAB#Version=2,0,0,1\"></object>";
-->
</script>

編集: JavaScript を有効にしているユーザーにはオブジェクトが表示されないため、JavaScript を使用しないことをお勧めします。HTMLに配置するだけの方が良いでしょう。

于 2008-11-11T15:57:48.477 に答える